Submission #80855

# Submission time Handle Problem Language Result Execution time Memory
80855 2018-10-22T14:39:11 Z luckyboy Doktor (COCI17_doktor) C++14
60 / 100
1000 ms 10216 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 ""
using namespace std;
int n,a[maxn],b[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);
    scanf("%d",&n);
    FOR(i,1,n)
    {
        scanf("%d",&a[i]),b[i] = a[i],a[i] += i;
        sum[i] = sum[i-1] + (b[i] == i);
    }
    FOR(i,1,n)
    {
        FOR(j,1,2*n) cnt[j] = 0;
        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;
            }
        }
    }
    a[l] -= l;
    if (l != r) a[r] -= r;
    printf("%d %d",a[l],a[r]);
}

Compilation message

doktor.cpp: In function 'int main()':
doktor.cpp:20:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&n);
     ~~~~~^~~~~~~~~
doktor.cpp:23:38: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",&a[i]),b[i] = a[i],a[i] += i;
         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~
# 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 464 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 544 KB Output is correct
2 Correct 2 ms 544 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 544 KB Output is correct
2 Correct 8 ms 584 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 38 ms 588 KB Output is correct
2 Correct 15 ms 716 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 60 ms 716 KB Output is correct
2 Correct 3 ms 716 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 200 ms 820 KB Output is correct
2 Execution timed out 1070 ms 6636 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Execution timed out 1072 ms 6636 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1070 ms 10216 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1062 ms 10216 KB Time limit exceeded
2 Halted 0 ms 0 KB -