Submission #86097

#TimeUsernameProblemLanguageResultExecution timeMemory
86097ffrichPreokret (COCI18_preokret)C++14
50 / 50
3 ms596 KiB
#include<iostream> #include<algorithm> #include<cstdio> #include<vector> using namespace std; vector < pair < int , int > > lebronzejames; int main(){ int ans1 = 0, ans2 = 0; int A; cin >> A; for(int i = 0; i < A; i++){ int min; cin >> min; if(min <= 1440) ans1++; lebronzejames.push_back(make_pair(min,1)); } int B; cin >> B; for(int i = 0; i < B; i++){ int min; cin >> min; if(min <= 1440) ans1++; lebronzejames.push_back(make_pair(min,-1)); } sort(lebronzejames.begin(),lebronzejames.end()); int lastdiff = 0; int vodstvo = 0; for(int i = 0; i < A+B; i++){ lastdiff += lebronzejames[i].second; if(lastdiff > 0 && vodstvo == -1){ ans2++; vodstvo = 1; } else if(lastdiff < 0 && vodstvo == 1){ ans2++; vodstvo = -1; } else if(lastdiff > 0 && vodstvo == 0) vodstvo = 1; else if(lastdiff < 0 && vodstvo == 0) vodstvo = -1; } cout << ans1 << endl << ans2; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...