#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <cctype>
#include <ctime>
using namespace std;
int na, a[2883], nb, b[2883], sol1, sol2, ba, bb, sl[2883], j;
int main(){
cin >> na;
for(int i = 0; i < na; i++){
cin >> a[i];
if (a[i] <= 1440)
sol1 = sol1 + 1;
}
cin >> nb;
for(int i = 0; i < nb; i++){
cin >> b[i];
if (b[i] <= 1440)
sol1 = sol1 + 1;
}
for(int i = 1; i <= 2883; i++){
if (a[ba] == i){
sl[j] = 1;
j = j + 1;
ba = ba + 1;
}
if (b[bb] == i){
sl[j] = 2;
j = j + 1;
bb = bb + 1;
}
}
ba = 0;
bb = 0;
for (int i = 0; i < (na + nb); i++){
if(sl[i] == 1){
ba = ba + 1;
}
if(sl[i] == 2){
bb = bb + 1;
}
if(ba == (bb - 1) and sl[i + 1] == 1 and sl[i + 2] == 1)
sol2 = sol2 + 1;
if(bb == (ba - 1) and sl[i + 1] == 2 and sl[i + 2] == 2)
sol2 = sol2 + 1;
}
cout << sol1 << endl << sol2;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
528 KB |
Output is correct |
4 |
Correct |
2 ms |
528 KB |
Output is correct |
5 |
Correct |
3 ms |
584 KB |
Output is correct |
6 |
Correct |
3 ms |
628 KB |
Output is correct |
7 |
Correct |
3 ms |
764 KB |
Output is correct |
8 |
Correct |
3 ms |
772 KB |
Output is correct |
9 |
Correct |
3 ms |
800 KB |
Output is correct |
10 |
Correct |
2 ms |
812 KB |
Output is correct |