# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
166064 | 2019-11-30T14:19:09 Z | itiam | Preokret (COCI18_preokret) | C++11 | 3 ms | 380 KB |
#include <iostream> #include <algorithm> #include <cstdio> using namespace std; int La[2883],Lb[2883]; int main(){ int Na,Nb,x,m=0,mm,pp=0,brop=0; //pp=prije poluvremena, brop=brojac preokreta, m=max, mm=minimal.. cin >> Na; for (int i=0;i<Na;i++){ cin >> x; if (x>m) m=x; if (x<mm || i==0) mm=x; if (x<=1440) pp+=1; La[x]=1; } cin >> Nb; for (int i=0;i<Nb;i++){ cin >> x; if (x>m) m=x; if (x<mm) mm=x; if (x<=1440) pp+=1; Lb[x]=1; } int p=0,pv; if (La[mm]==1) pv=-1; else if (Lb[mm]==1) pv=1; for (int i=mm;i<=m;i++){ if (La[i]==1){ p+=1; } else if (Lb[i]==1){ p-=1; } if (p*pv>0){ brop+=1; pv*=-1; } } cout << pp << "\n"; cout << brop; return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 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 | 3 ms | 376 KB | Output is correct |
8 | Correct | 3 ms | 380 KB | Output is correct |
9 | Correct | 3 ms | 376 KB | Output is correct |
10 | Correct | 2 ms | 376 KB | Output is correct |