/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Wrong Answer 4ms 532.0 KiB

Code

#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define endl '\n'

const int nn = 1e5 + 17, mod = 1e9 + 7;
int n, A[nn], B[nn];

void Try() {
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> A[i];
    }
    
    for (int i = 1; i <= n; i++) {
        cin >> B[i];
    }
    
    ll ans = 0;
    priority_queue<int, vector<int>, greater<int>> Mn;
    
    int mx = 0;
    for (int i = 1; i <= n; i++) {
        Mn.push(A[i]);
        mx = max(mx, B[i]);
    }
    
    while(Mn.size() && Mn.top() < mx) {
        ans += (mx - Mn.top());
        Mn.pop();
    }
    
    cout << ans << endl;
}

int32_t main() {
    ios_base::sync_with_stdio(0); cin.tie(0);

    int t = 1;
    cin >> t;
    for (int i = 1; i <= t; i++) {
        Try();
    }

}

Information

Submit By
Type
Pretest
Problem
P1228 Business Strategy
Language
C++17 (G++ 13.2.0)
Submit At
2025-09-01 07:08:26
Judged At
2025-09-01 07:08:26
Judged By
Score
0
Total Time
4ms
Peak Memory
532.0 KiB