Submission #152824

# Submission time Handle Problem Language Result Execution time Memory
152824 2019-09-09T17:22:04 Z phillip Doktor (COCI17_doktor) C++14
30 / 100
1000 ms 632 KB
#include <bits/stdc++.h>

using namespace std;
int n,a[5009];
int c(int l,int r)
{
    int ret=0;
    for(int i=l;i<=r;i++)
    {
        if(a[r-(i-l)]==i)ret++;
    }
    return ret;
}
int l[5009],r[5009];
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    for(int i=1;i<=n;i++)
    {
        l[i]=l[i-1];
        if(a[i]==i)l[i]++;
    }
    for(int i=n;i>=1;i--)
    {
        r[i]=r[i+1];
        if(a[i]==i)r[i]++;
    }
    int sum,mx=0,x,y;
    for(int i=1;i<=n;i++)
    {
        for(int j=i;j<=n;j++)
        {
            sum=c(i,j)+l[i-1]+r[j+1];
            mx=max(sum,mx);
            if(mx==sum)
            {
                x=i;
                y=j;
            }
        }
    }
    cout<<a[x]<<" "<<a[y];
}

Compilation message

doktor.cpp: In function 'int main()':
doktor.cpp:46:25: warning: 'y' may be used uninitialized in this function [-Wmaybe-uninitialized]
     cout<<a[x]<<" "<<a[y];
                         ^
doktor.cpp:46:17: warning: 'x' may be used uninitialized in this function [-Wmaybe-uninitialized]
     cout<<a[x]<<" "<<a[y];
                 ^~~
# 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 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 356 KB Output is correct
2 Correct 13 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1079 ms 376 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1057 ms 376 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1058 ms 376 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1076 ms 376 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 5 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 6 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 6 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -