Submission #1025823

#TimeUsernameProblemLanguageResultExecution timeMemory
1025823vjudge1Doktor (COCI17_doktor)C++17
100 / 100
177 ms38580 KiB
#include <bits/stdc++.h> using namespace std; int main() { int n; cin>>n; vector<int> a,fx,len[2*n]; for (int i=0;i<n;i++) { int x; cin>>x; a.push_back(x); a.push_back(0); } for (int i=0;i<2*n-1;i+=2) { int rc=2*a[i]-2; if (rc==i) fx.push_back(i); else len[(i+rc)/2].push_back((i+rc)/2-min(i,rc)); } int dt=0,st=1,en=1; for (int id=0;id<2*n-1;id++) { sort(len[id].begin(),len[id].end()); for (int i=0;i<len[id].size();i++) { int l=id-len[id][i],r=id+len[id][i]; int del=i+1; auto x=lower_bound(fx.begin(),fx.end(),l),y=upper_bound(fx.begin(),fx.end(),r); del-=y-x; if (del>dt) dt=del,st=a[l],en=a[r]; } } cout<<st<<' '<<en<<endl; return 0; }

Compilation message (stderr)

doktor.cpp: In function 'int main()':
doktor.cpp:29:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |   for (int i=0;i<len[id].size();i++)
      |                ~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...