#include <bits/stdc++.h>
using namespace std;
int a, b, suma, sumb, trn, half;
priority_queue<pair<int, int> > pq;
int main(){
cin >> a;
while(a--){
int t;
cin >> t;
pq.push({-t, 0});
}
cin >> b;
while(b--){
int t;
cin >> t;
pq.push({-t, 1});
}
int kayb = -1;
while(!pq.empty()){
pair<int, int> curr = pq.top();
pq.pop();
if(-curr.first <= 1440) half++;
if(curr.second == 0){
suma++;
}else{
sumb++;
}
if(kayb == 0 && suma > sumb) trn++;
else if(kayb == 1 && sumb > suma) trn++;
if(suma != sumb) kayb = suma > sumb;
}
cout << half << "\n" << trn;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
288 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
296 KB |
Output is correct |
5 |
Correct |
1 ms |
292 KB |
Output is correct |
6 |
Correct |
1 ms |
296 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
332 KB |
Output is correct |
10 |
Correct |
0 ms |
204 KB |
Output is correct |