# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
96701 | nandonathaniel | Preokret (COCI18_preokret) | C++14 | 3 ms | 376 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |