/ SeriousOJ /

Record Detail

Compile Error

foo.cc: In function 'void Try()':
foo.cc:21:25: error: two or more data types in declaration of 'type name'
   21 |     priority_queue<int, vector<int> greater<int>> Mn;
      |                         ^~~~~~~~~~~
foo.cc:21:48: error: template argument 2 is invalid
   21 |     priority_queue<int, vector<int> greater<int>> Mn;
      |                                                ^~
foo.cc:21:48: error: template argument 3 is invalid
foo.cc:25:12: error: request for member 'push' in 'Mn', which is of non-class type 'int'
   25 |         Mn.push(A[i]);
      |            ^~~~
foo.cc:26:23: error: request for member 'top' in 'Mn', which is of non-class type 'int'
   26 |         if (B[i] > Mn.top()) {
      |                       ^~~
foo.cc:27:30: error: request for member 'top' in 'Mn', which is of non-class type 'int'
   27 |             ans += B[i] - Mn.top();
      |                              ^~~
foo.cc:28:16: error: request for member 'pop' in 'Mn', which is of non-class type 'int'
   28 |             Mn.pop();
      |                ^~~

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;
    priority_queue<int>Mx;
    
    for (int i = 1; i <= n; i++) {
        Mn.push(A[i]);
        if (B[i] > Mn.top()) {
            ans += B[i] - 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:04:13
Judged At
2025-09-01 07:04:13
Judged By
Score
0
Total Time
0ms
Peak Memory
0 Bytes