# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
80856 |
2018-10-22T14:43:51 Z |
luckyboy |
Doktor (COCI17_doktor) |
C++14 |
|
1000 ms |
8188 KB |
/** Lucky Boy **/
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define FORD(i, a, b) for (int i = (a); i >= (b); --i)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define maxc 1000000007
#define maxn 500005
#define maxm 500005
#define pii pair <int,int>
#define Task ""
template <typename T> inline void read(T &x){char c;bool nega=0;while((!isdigit(c=getchar()))&&(c!='-'));if(c=='-'){nega=1;c=getchar();}x=c-48;while(isdigit(c=getchar())) x=x*10+c-48;if(nega) x=-x;}
template <typename T> inline void writep(T x){if(x>9) writep(x/10);putchar(x%10+48);}
template <typename T> inline void write(T x){if(x<0){putchar('-');x=-x;}writep(x);putchar(' ');}
template <typename T> inline void writeln(T x){write(x);putchar('\n');}
using namespace std;
int n,a[maxn],cnt[maxn << 1],ans,l,r,sum[maxn];
int main()
{
//ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
//freopen(".inp", "r",stdin);
read(n);
FOR(i,1,n)
{
read(a[i]);
sum[i] = sum[i-1] + (a[i] == i);
a[i] += i;
}
FOR(i,1,n)
{
FOR(j,i,n)
{
++cnt[a[j]];
if (cnt[i+j] + sum[i-1] + sum[n] - sum[j-1] > ans)
{
ans = cnt[i+j] + sum[i-1] + sum[n] - sum[j-1];
l = i,r = j;
}
}
FOR(j,i,n) cnt[a[j]] = 0;
}
a[l] -= l;
if (l != r) a[r] -= r;
write(a[l]);
write(a[r]);
}
# |
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 |
448 KB |
Output is correct |
2 |
Correct |
3 ms |
524 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
604 KB |
Output is correct |
2 |
Correct |
5 ms |
604 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
29 ms |
748 KB |
Output is correct |
2 |
Correct |
10 ms |
748 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
49 ms |
748 KB |
Output is correct |
2 |
Correct |
3 ms |
748 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
204 ms |
804 KB |
Output is correct |
2 |
Execution timed out |
1050 ms |
2940 KB |
Time limit exceeded |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1079 ms |
2940 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1082 ms |
8188 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1083 ms |
8188 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |