# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
670917 | 2022-12-11T10:36:07 Z | BidoTeima | Doktor (COCI17_doktor) | C++17 | 264 ms | 46936 KB |
/* ID: BidoTeima LANG: C++11 TASK: */ #include <bits/stdc++.h> using namespace std; using ll = long long; void moo(string filename); void ACPLS(string str = "") { if(str=="NOF")return; if(str.size()) moo(str); else{ #ifndef ONLINE_JUDGE freopen("output.txt", "w", stdout); freopen("input.txt", "r", stdin); #endif } ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); } void moo(string fileName){ freopen((fileName+".in").c_str(),"r",stdin); freopen((fileName+".out").c_str(),"w",stdout); } #define tc \ int tttttt/*,subtask*/; \ cin >> tttttt/* >> subtask*/; \ while (tttttt--)/*end */ int main() { //ACPLS(); int n; cin>>n; vector<pair<int,int>>v[2 * n + 1]; int pos[n+1],a[n + 1]; int ps[n + 1]={0}; for(int i = 1; i <= n; i++){ int x; cin>>x; a[i] = x; pos[x] = i; if(i == x){ ps[i]++; //ans++; } ps[i] += ps[i - 1]; } for(int i = 1; i <= n; i++){ v[i + pos[i]].push_back({min(i, pos[i]), max(i, pos[i])}); //cout<<ps[i]<<'\n'; } int res = 0; pair<int,int>ans={1,1}; for(int i = 1; i <= 2 * n; i++){ sort(v[i].begin(), v[i].end()); for(int j = 0; j < (int)v[i].size(); j++){ // contribution = no of (x,y) inside - no opf fixed points inside if((int)v[i].size() - j - (ps[v[i][j].second] - ps[v[i][j].first - 1]) > res){ res = (int)v[i].size() - j - (ps[v[i][j].second] - ps[v[i][j].first - 1]); ans={v[i][j].first,v[i][j].second}; } //cout<<res<<' '<<v[i][j].first<<' '<<v[i][j].second<<'\n'; } } cout<<a[ans.first]<<' '<<a[ans.second]<<'\n'; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 468 KB | Output is correct |
2 | Correct | 1 ms | 340 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 596 KB | Output is correct |
2 | Correct | 1 ms | 468 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 596 KB | Output is correct |
2 | Correct | 1 ms | 340 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 1108 KB | Output is correct |
2 | Correct | 120 ms | 24000 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 37 ms | 8140 KB | Output is correct |
2 | Correct | 37 ms | 7796 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 264 ms | 43852 KB | Output is correct |
2 | Correct | 202 ms | 37276 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 149 ms | 25792 KB | Output is correct |
2 | Correct | 175 ms | 46936 KB | Output is correct |