# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
473632 | 2021-09-15T18:36:28 Z | MamdouhN | Doktor (COCI17_doktor) | C++17 | 592 ms | 38056 KB |
#include<bits/stdc++.h> using namespace std; #define int long long #define endl "\n" map<pair<int,int>,int>idk; main() { int n; cin>>n; int ar[n]; int doingnothing=0; vector<int>lol; lol.push_back(0); for(int i=0;i<n;i++) { cin>>ar[i]; if(ar[i]==i+1)doingnothing++; int x = min(ar[i]-1,i); int y = max(ar[i]-1,i); int dist = min(x - 0 , n - y-1); //cout<<x-dist<<" "<<y+dist<<endl; idk[{ x-dist , y+dist }]++; lol.push_back(doingnothing); } int x = 0; pair<int,int>ans; for(auto v:idk) { int z = lol[v.first.second+1] - lol[v.first.first]; if(v.second-z>=x) { x = v.second; ans = v.first; } } cout<<ar[ans.first]<<" "<<ar[ans.second]<<endl; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 204 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 332 KB | Output is correct |
2 | Correct | 1 ms | 332 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 588 KB | Output is correct |
2 | Correct | 2 ms | 332 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 332 KB | Output is correct |
2 | Incorrect | 1 ms | 332 KB | Output isn't correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 896 KB | Output is correct |
2 | Correct | 118 ms | 6768 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 64 ms | 5748 KB | Output is correct |
2 | Correct | 32 ms | 2216 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 592 ms | 30500 KB | Output is correct |
2 | Correct | 172 ms | 8368 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 308 ms | 18844 KB | Output is correct |
2 | Correct | 304 ms | 38056 KB | Output is correct |