#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
int a,b,ans1,ans2;
int arr[3005];
signed main(){
ios::sync_with_stdio(false);
cin.tie(NULL);
cin >> a;
for(int i=1;i<=a;i++){
int x;
cin >> x;
if(x<=1440){
ans1++;
}
arr[x]++;
}
cin >> b;
for(int i=1;i<=b;i++){
int x;
cin >> x;
if(x<=1440){
ans1++;
}
arr[x]--;
}
int curr=0;
for(int i=1;i<=3000;i++){
arr[i] += arr[i-1];
if(curr==0){
if(arr[i]>0){
curr = 1;
}
else if(arr[i]<0){
curr = -1;
}
}
else if(arr[i]>0 and curr<0){
ans2++;
curr = 1;
}
else if(arr[i]<0 and curr>0){
ans2++;
curr = -1;
}
}
cout << ans1 << "\n";
cout << ans2 << "\n";
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
324 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
344 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |