# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
670918 | 2022-12-11T10:36:35 Z | BidoTeima | Doktor (COCI17_doktor) | C++17 | 263 ms | 43768 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 | 0 ms | 212 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 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 | 340 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 | 3 ms | 1108 KB | Output is correct |
2 | Correct | 119 ms | 22108 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 34 ms | 7616 KB | Output is correct |
2 | Correct | 37 ms | 7260 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 263 ms | 40684 KB | Output is correct |
2 | Correct | 194 ms | 33852 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 162 ms | 24060 KB | Output is correct |
2 | Correct | 166 ms | 43768 KB | Output is correct |