| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 141072 | 44442 | Preokret (COCI18_preokret) | C++11 | 4 ms | 504 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;
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 (stderr)
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
