Submission #141072

#TimeUsernameProblemLanguageResultExecution timeMemory
14107244442Preokret (COCI18_preokret)C++11
50 / 50
4 ms504 KiB
#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)

preokret.cpp: In function 'int main()':
preokret.cpp:8:12: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
       scanf("%d\n",&a);
       ~~~~~^~~~~~~~~~~
preokret.cpp:10:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d\n",&as[i]);
         ~~~~~^~~~~~~~~~~~~~~
preokret.cpp:16:12: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
       scanf("%d",&b);
       ~~~~~^~~~~~~~~
preokret.cpp:18:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("\n%d",&bs[j]);
         ~~~~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...