#include <bits/stdc++.h>
using namespace std;
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mem(a,b) memset(a, b, sizeof(a))
#define F first
#define S second
#define Si size
#define pb(x) push_back(x)
typedef double D;
typedef long long ll;
typedef long double ld;
const int MOD=(int)1e9+7,MAX=(int)1e5+10;
int n,a[5000],m,b[5000],half;
int as[5000],bs[5000],first,ans;
int main()
{
cin>>n;
for (int i=0;i<n;i++) {
cin>>a[i];
if (a[i]<=2880/2) half++;
as[a[i]]++;
}
cin>>m;
for (int i=0;i<m;i++) {
cin>>b[i];
if (b[i]<=2880/2) half++;
bs[b[i]]++;
}
cout<<half<<endl;
first=min(a[0],b[0]);
int scorea=(first==a[0])? 1:0;
int scoreb=(first==b[0])? 1:0;
bool x=(scorea>scoreb);
for (int i=first+1;i<=2880;i++) {
scorea+=as[i];
scoreb+=bs[i];
if (scorea>scoreb) {
if (x==0) {
x=1;
ans++;
}
}
if (scorea<scoreb) {
if (x==1) {
x=0;
ans++;
}
}
}
cout<<ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
256 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
3 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
256 KB |
Output is correct |
6 |
Correct |
3 ms |
384 KB |
Output is correct |
7 |
Correct |
2 ms |
384 KB |
Output is correct |
8 |
Correct |
3 ms |
384 KB |
Output is correct |
9 |
Correct |
4 ms |
384 KB |
Output is correct |
10 |
Correct |
2 ms |
384 KB |
Output is correct |