# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1025823 |
2024-07-17T10:27:32 Z |
vjudge1 |
Doktor (COCI17_doktor) |
C++17 |
|
177 ms |
38580 KB |
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin>>n;
vector<int> a,fx,len[2*n];
for (int i=0;i<n;i++)
{
int x;
cin>>x;
a.push_back(x);
a.push_back(0);
}
for (int i=0;i<2*n-1;i+=2)
{
int rc=2*a[i]-2;
if (rc==i)
fx.push_back(i);
else
len[(i+rc)/2].push_back((i+rc)/2-min(i,rc));
}
int dt=0,st=1,en=1;
for (int id=0;id<2*n-1;id++)
{
sort(len[id].begin(),len[id].end());
for (int i=0;i<len[id].size();i++)
{
int l=id-len[id][i],r=id+len[id][i];
int del=i+1;
auto x=lower_bound(fx.begin(),fx.end(),l),y=upper_bound(fx.begin(),fx.end(),r);
del-=y-x;
if (del>dt)
dt=del,st=a[l],en=a[r];
}
}
cout<<st<<' '<<en<<endl;
return 0;
}
Compilation message
doktor.cpp: In function 'int main()':
doktor.cpp:29:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
29 | for (int i=0;i<len[id].size();i++)
| ~^~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
432 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
856 KB |
Output is correct |
2 |
Correct |
1 ms |
604 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
684 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
1112 KB |
Output is correct |
2 |
Correct |
94 ms |
21512 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
30 ms |
7360 KB |
Output is correct |
2 |
Correct |
27 ms |
7628 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
177 ms |
38580 KB |
Output is correct |
2 |
Correct |
147 ms |
31632 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
101 ms |
23432 KB |
Output is correct |
2 |
Correct |
129 ms |
30648 KB |
Output is correct |