# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
141072 | 2019-08-06T13:49:09 Z | 44442 | Preokret (COCI18_preokret) | C++11 | 4 ms | 504 KB |
#include <bits/stdc++.h> using namespace std; int a,b,as[2890],bs[2890],ok,okk,aa[2890],bb[2890],c[2890],va[2890],vb[2890]; set<int>s; int main (){ ios::sync_with_stdio(0); //cin.tie(0); cout.tie(0); scanf("%d\n",&a); for(int i=0;i<a;i++){ scanf("%d\n",&as[i]); if(as[i]<1441) ok++; aa[as[i]]=1; s.insert(as[i]); } scanf("%d",&b); for(int j=0;j<b;j++){ scanf("\n%d",&bs[j]); if(bs[j]<1441) ok++; bb[bs[j]]=1; s.insert(bs[j]); } printf("%d\n",ok); for(set<int>::iterator it=s.begin();it!=s.end();it++){ set<int>::iterator itt=s.lower_bound(*it); itt--; if(aa[*it]==1){ va[*it]=va[*itt]+1; } else va[*it]=va[*itt]; if(bb[*it]==1){ vb[*it]=vb[*itt]+1; } else vb[*it]=vb[*itt]; if(va[*it]>vb[*it]) c[*it]=1; else if(vb[*it]>va[*it]) c[*it]=2; else c[*it]=0; } set<int>::iterator it=s.begin(); it++; while(it!=s.end()){ set<int>::iterator d=s.lower_bound(*it); d--; set<int>::iterator itt=s.lower_bound(*d); itt--; if((c[*it]==1 and c[*itt]==2) or (c[*it]==2 and c[*itt]==1)) okk++; it++; } printf("%d",okk); return 0; }
Compilation message
# | Verdict | Execution time | Memory | 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 | 3 ms | 504 KB | Output is correct |
7 | Correct | 3 ms | 504 KB | Output is correct |
8 | Correct | 3 ms | 504 KB | Output is correct |
9 | Correct | 4 ms | 504 KB | Output is correct |
10 | Correct | 2 ms | 376 KB | Output is correct |