#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
int preA[6005],preB[6005],kode[6005];
int main(){
vector<pii> V;
int a,b,x,ans1=0;
cin >> a;
for(int i=0;i<a;i++){
cin >> x;
V.push_back(make_pair(x,0));
if(x<=1440)ans1++;
}
cin >> b;
for(int i=0;i<b;i++){
cin >> x;
V.push_back(make_pair(x,1));
if(x<=1440)ans1++;
}
sort(V.begin(),V.end());
for(int i=0;i<V.size();i++){
if(i==0){
if(V[i].second==0){
preA[i]=1;
preB[i]=0;
}
if(V[i].second==1){
preB[i]=1;
preA[i]=0;
}
}
else{
if(V[i].second==0){
preA[i]=preA[i-1]+1;
preB[i]=preB[i-1];
}
if(V[i].second==1){
preB[i]=preB[i-1]+1;
preA[i]=preA[i-1];
}
}
}
for(int i=0;i<V.size();i++){
if(preA[i]>preB[i])kode[i]=0;
if(preB[i]>preA[i])kode[i]=1;
if(preA[i]==preB[i])kode[i]=kode[i-1];
}
int ans2=0;
for(int i=1;i<V.size();i++){
if(kode[i]!=kode[i-1])ans2++;
}
cout << ans1 << "\n";
cout << ans2 << "\n";
return 0;
}
Compilation message
preokret.cpp: In function 'int main()':
preokret.cpp:23:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0;i<V.size();i++){
~^~~~~~~~~
preokret.cpp:45:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0;i<V.size();i++){
~^~~~~~~~~
preokret.cpp:51:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=1;i<V.size();i++){
~^~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
256 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
3 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |