#include<iostream>
#include<algorithm>
#include<cstdio>
#include<vector>
using namespace std;
vector < pair < int , int > > lebronzejames;
int main(){
int ans1 = 0, ans2 = 0;
int A; cin >> A;
for(int i = 0; i < A; i++){
int min; cin >> min;
if(min <= 1440) ans1++;
lebronzejames.push_back(make_pair(min,1));
}
int B; cin >> B;
for(int i = 0; i < B; i++){
int min; cin >> min;
if(min <= 1440) ans1++;
lebronzejames.push_back(make_pair(min,-1));
} sort(lebronzejames.begin(),lebronzejames.end());
int lastdiff = 0;
int vodstvo = 0;
for(int i = 0; i < A+B; i++){
lastdiff += lebronzejames[i].second;
if(lastdiff > 0 && vodstvo == -1){
ans2++;
vodstvo = 1;
}
else if(lastdiff < 0 && vodstvo == 1){
ans2++;
vodstvo = -1;
}
else if(lastdiff > 0 && vodstvo == 0) vodstvo = 1;
else if(lastdiff < 0 && vodstvo == 0) vodstvo = -1;
} cout << ans1 << endl << ans2;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
372 KB |
Output is correct |
3 |
Correct |
2 ms |
576 KB |
Output is correct |
4 |
Correct |
2 ms |
576 KB |
Output is correct |
5 |
Correct |
2 ms |
576 KB |
Output is correct |
6 |
Correct |
3 ms |
576 KB |
Output is correct |
7 |
Correct |
3 ms |
576 KB |
Output is correct |
8 |
Correct |
3 ms |
596 KB |
Output is correct |
9 |
Correct |
3 ms |
596 KB |
Output is correct |
10 |
Correct |
2 ms |
596 KB |
Output is correct |