# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
154371 | 2019-09-21T10:07:50 Z | PedroBigMan | Doktor (COCI17_doktor) | C++14 | 326 ms | 48992 KB |
#include <iostream> #include <vector> #include <cmath> #include <algorithm> #include <string> using namespace std; typedef long long int ll; typedef unsigned long long int ull; typedef long double ld; #define REP(i,a,b) for(ll i=a; i<b; i++) #define pb push_back #define mp make_pair #define pl pair<ll,ll> #define ff first #define ss second #define INF ((ll) pow(2,63) -1) #define si signed ll insig; #define In(vecBRO, LENBRO) REP(IBRO,0,LENBRO) {cin>>insig; vecBRO.pb(insig);} void Out(vector<ll> x) {REP(i,0,x.size()) {cout<<x[i]<<" ";} cout<<endl;} int main() { ios_base::sync_with_stdio(0); cin.tie(0); ll N; cin>>N; vector<ll> a; In(a,N); vector<ll> p; ll cur=0; REP(i,0,N) { if(a[i]==i+1) {cur++;} p.pb(cur); } ll ideal; vector<vector<ll> > cen; vector<ll> xx; REP(i,0,2*N-1) {cen.pb(xx);} REP(i,0,N) { ideal = i+a[i]-1; cen[ideal].pb(abs(i+1-a[i])); } REP(i,0,2*N-1) {sort(cen[i].begin(),cen[i].end());} ll A=1; ll B=1; ll best=0; REP(c,1,2*N-1) { REP(i,0,cen[c].size()) { if(c-cen[c][i]==0) { if(i+1-p[c]>best) { best=i+1-p[c]; A=a[0]; B=a[c]; } } else { if(i+1-(p[(c+cen[c][i])/2]-p[(c-cen[c][i])/2 -1]) >best) { best=i+1-(p[(c+cen[c][i])/2]-p[(c-cen[c][i])/2 -1]); A=a[(c-cen[c][i])/2]; B=a[(c+cen[c][i])/2]; } } } } cout<<A<<" "<<B<<endl; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 720 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 504 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 348 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 632 KB | Output is correct |
2 | Correct | 3 ms | 504 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 1000 KB | Output is correct |
2 | Correct | 3 ms | 760 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 1000 KB | Output is correct |
2 | Correct | 2 ms | 504 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 1588 KB | Output is correct |
2 | Correct | 131 ms | 34732 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 47 ms | 9192 KB | Output is correct |
2 | Correct | 41 ms | 9428 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 326 ms | 46020 KB | Output is correct |
2 | Correct | 195 ms | 43020 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 192 ms | 34456 KB | Output is correct |
2 | Correct | 163 ms | 48992 KB | Output is correct |