Submission #200927

# Submission time Handle Problem Language Result Execution time Memory
200927 2020-02-08T15:33:12 Z SamAnd Doktor (COCI17_doktor) C++17
10 / 100
281 ms 42620 KB
#include <bits/stdc++.h>
using namespace std;
#define m_p make_pair
const int N = 500005;

int n;
int a[N];

int p[N];

vector<pair<int, int> > v[N + N];

int ans;
int ansl, ansr;

int main()
{
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i)
        scanf("%d", &a[i]);
    for (int i = 1; i <= n; ++i)
    {
        p[i] = p[i - 1];
        if (a[i] == i)
            ++p[i];
        int x = n - min(i, a[i]) + 1;
        int y = max(i, a[i]);
        v[x - y + n].push_back(m_p(min(i, a[i]), max(i, a[i])));
    }
    ans = p[n];
    ansl = ansr = 1;
    for (int i = 0; i <= n + n; ++i)
    {
        sort(v[i].begin(), v[i].end());
        reverse(v[i].begin(), v[i].end());
        for (int j = 0; j < v[i].size(); ++j)
        {
            int l = v[i][j].first, r = v[i][j].second;
            if ((j + 1) + p[l - 1] + p[n] - p[r] - (p[r] - p[l - 1]) > ans)
            {
                ans = (j + 1) + p[l - 1] + p[n] - p[r] - (p[r] - p[l - 1]);
                ansl = l;
                ansr = r;
            }
        }
    }
    printf("%d %d\n", ansr, ansl);
    return 0;
}

Compilation message

doktor.cpp: In function 'int main()':
doktor.cpp:36:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (int j = 0; j < v[i].size(); ++j)
                         ~~^~~~~~~~~~~~~
doktor.cpp:18:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
     ~~~~~^~~~~~~~~~
doktor.cpp:20:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &a[i]);
         ~~~~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 20 ms 23800 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 24 ms 23800 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 24 ms 23800 KB Output is correct
2 Failed 19 ms 23800 KB Checker failed - contact admins or jury
# Verdict Execution time Memory Grader output
1 Incorrect 20 ms 23928 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 21 ms 23976 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 21 ms 23920 KB Output is correct
2 Incorrect 20 ms 23800 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 24 ms 24184 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 50 ms 27128 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 281 ms 42620 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 144 ms 34808 KB Output isn't correct
2 Halted 0 ms 0 KB -