Submission #99741

#TimeUsernameProblemLanguageResultExecution timeMemory
99741Sa1loumPreokret (COCI18_preokret)C++14
50 / 50
4 ms384 KiB
#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; }
#Verdict Execution timeMemoryGrader output
Fetching results...