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; }

    Information

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