4 条题解

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

    信息

    ID
    370
    时间
    1000ms
    内存
    64MiB
    难度
    6
    标签
    递交数
    29
    已通过
    12
    上传者