# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
166018 | 2019-11-30T08:14:22 Z | theStaticMind | Doktor (COCI17_doktor) | C++14 | 264 ms | 45708 KB |
#include<bits/stdc++.h> #define mp make_pair #define pb push_back #define ii pair<int,int> #define all(x) (x).begin(),(x).end() #define INF 100000000000000000 #define modulo 1000000007 #define mod 998244353 #define int long long int using namespace std; int32_t main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); // freopen("q.gir","r",stdin); // freopen("q.cik","w",stdout); int n; cin>>n; vector<int> arr(n+1),pre(n+1,0); for(int i=1;i<=n;i++)cin>>arr[i]; vector<vector<int> >data(2*n+1); for(int i=1;i<=n;i++){ data[arr[i]+i].pb(abs(arr[i]-i)); } for(int i=1;i<=n;i++){ if(arr[i]==i)pre[i]++; } for(int i=1;i<=n;i++)pre[i]+=pre[i-1]; int ans=0; int L=0,R=0; for(int i=0;i<=2*n;i++){ sort(all(data[i])); for(int j=0;j<data[i].size();j++){ int l=(i-data[i][j])/2; int r=(i+data[i][j])/2; int cnt=j+1+pre[l-1]+pre[n]-pre[r]; if(cnt>ans){ ans=cnt; L=l; R=r; } } } cout<<arr[L]<<" "<<arr[R]; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 380 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 480 KB | Output is correct |
2 | Correct | 2 ms | 504 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 760 KB | Output is correct |
2 | Correct | 3 ms | 548 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 760 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 1272 KB | Output is correct |
2 | Correct | 93 ms | 23404 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 32 ms | 8152 KB | Output is correct |
2 | Correct | 31 ms | 8308 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 264 ms | 42712 KB | Output is correct |
2 | Correct | 156 ms | 35864 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 137 ms | 25184 KB | Output is correct |
2 | Correct | 127 ms | 45708 KB | Output is correct |