#include <bits/stdc++.h>
using namespace std;
int n, m, a[3000], dp[3000], ans;
int main(){
cin >> n;
for(int i = 1; i <= n; i++){
int l;
cin >> l;
a[l] = 1;
}
cin >> m;
for(int i = 1; i <= m; i++){
int l;
cin >> l;
a[l] = 2;
}
int k1 = 0, k2 = 0;
for(int i = 1; i <= 2880; i++){
if(a[i] == 1){
k1++;
}
if(a[i] == 2){
k2++;
}
if(k1 == k2){
dp[i] = dp[i - 1];
}
else if(k1 < k2){
dp[i] = 2;
}
else{
dp[i] = 1;
}
if(i == 1440){
cout << k1 + k2 << "\n";
}
if((dp[i] == 1 && dp[i - 1] == 2) || (dp[i] == 2 && dp[i - 1] == 1)){
ans++;
}
}
cout << ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
3 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
0 ms |
252 KB |
Output is correct |
6 |
Correct |
3 ms |
376 KB |
Output is correct |
7 |
Correct |
3 ms |
376 KB |
Output is correct |
8 |
Correct |
8 ms |
504 KB |
Output is correct |
9 |
Correct |
4 ms |
400 KB |
Output is correct |
10 |
Correct |
3 ms |
380 KB |
Output is correct |