4 solutions

  • 1
    @ 2025-7-18 16:51:01

    #include <bits/stdc++.h> using namespace std; int a[25005], b[25005];

    int main() { int n, x, y, s = 0; cin >> n >> x >> y; for (int i = 0; i < n; i++) { cin >> a[i] >> b[i]; } sort(a, a + n); sort(b, b + n); for (int i = 0; i < n; i++) { if (a[i] > b[i]) s = s + (a[i] - b[i]) * y; if (a[i] < b[i]) s = s + (b[i] - a[i]) * x; } cout << s; return 0; }

    • 0
      @ 2025-7-18 16:51:05

      #include <bits/stdc++.h> using namespace std; int a[25005], b[25005];

      int main() { int n, x, y, s = 0; cin >> n >> x >> y; for (int i = 0; i < n; i++) { cin >> a[i] >> b[i]; } sort(a, a + n); sort(b, b + n); for (int i = 0; i < n; i++) { if (a[i] > b[i]) s = s + (a[i] - b[i]) * y; if (a[i] < b[i]) s = s + (b[i] - a[i]) * x; } cout << s; return 0; }

      • -1
        @ 2025-7-18 16:50:25

        #include <bits/stdc++.h> using namespace std; int a[25005], b[25005];

        int main() { int x, y, n, s = 0; cin >> n >> x >> y; for (int i = 0; i < n; i++) { cin >> a[i] >> b[i];

        }
        sort(a, a + n);
        sort(b, b + n);
        for (int i = 0; i < n; i++) {
        	if (a[i] > b[i])
        		s = s + (a[i] - b[i]) * y;
        	if (a[i] < b[i])
        		s = s + (b[i] - a[i]) * x;
        
        }
        cout << s ;
        return 0;
        

        }

        • -1
          @ 2025-7-18 16:48:06

          发个题解呗

          • 1

          Information

          ID
          370
          Time
          1000ms
          Memory
          64MiB
          Difficulty
          6
          Tags
          # Submissions
          29
          Accepted
          12
          Uploaded By