# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
170370 |
2019-12-24T23:58:27 Z |
mdn2002 |
Doktor (COCI17_doktor) |
C++14 |
|
235 ms |
45944 KB |
#include<bits/stdc++.h>
using namespace std;
const long long mod=998244353;
int n,a[500005],sum[500005];
vector<int>b[1000005];
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
//freopen("lemonade.in","r",stdin);
//freopen("lemonade.out","w",stdout);
cin>>n;
for(int i=1;i<=n;i++)
{
cin>>a[i];
if(i==a[i])sum[i]++;
sum[i]+=sum[i-1];
}
for(int i=1;i<=n;i++)b[i+a[i]].push_back(abs(a[i]-i));
int mx=0,a1=1,b1=1;
for(int i=2;i<=n*2;i++)
{
sort(b[i].begin(),b[i].end());
int cnt=0;
for(int j=0;j<b[i].size();j++)
{
cnt++;
int con=i,dis=b[i][j];
int l=(con-dis)/2,r=(con+dis)/2;
int ans=cnt-(sum[r]-sum[l-1]);
if(mx<ans)
{
mx=ans;
a1=l;
b1=r;
}
}
}
cout<<a[a1]<<' '<<a[b1];
}
Compilation message
doktor.cpp: In function 'int main()':
doktor.cpp:26:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int j=0;j<b[i].size();j++)
~^~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
24 ms |
23804 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
23 ms |
23800 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
23 ms |
23800 KB |
Output is correct |
2 |
Correct |
27 ms |
23928 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
29 ms |
23928 KB |
Output is correct |
2 |
Correct |
24 ms |
23928 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
25 ms |
23928 KB |
Output is correct |
2 |
Correct |
29 ms |
23900 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
24 ms |
24000 KB |
Output is correct |
2 |
Correct |
24 ms |
23784 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
26 ms |
24188 KB |
Output is correct |
2 |
Correct |
102 ms |
30444 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
57 ms |
27152 KB |
Output is correct |
2 |
Correct |
47 ms |
25848 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
235 ms |
42360 KB |
Output is correct |
2 |
Correct |
146 ms |
33264 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
136 ms |
34556 KB |
Output is correct |
2 |
Correct |
121 ms |
45944 KB |
Output is correct |