Submission #235135

# Submission time Handle Problem Language Result Execution time Memory
235135 2020-05-27T07:13:18 Z Vimmer Doktor (COCI17_doktor) C++14
30 / 100
800 ms 131076 KB
#include <bits/stdc++.h>

//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("-O3")
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("fast-math")
//#pragma GCC optimize("no-stack-protector")

#define F first
#define S second
#define sz(x) int(x.size())
#define pb push_back
#define N 500001
#define M ll(1e9 + 7)
#define inf 1e9 + 1e9

using namespace std;

typedef long double ld;
typedef long long ll;

typedef short int si;

unordered_map <int, int> mp[N];

int a[N], mx[N];

int main()
{
//    freopen("input4.txt", "r", stdin); freopen("output4.txt", "w", stdout);

    ios_base::sync_with_stdio(0); istream::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    int n;

    cin >> n;

    for (int i = 1; i <= n; i++) cin >> a[i];

    for (int i = 1; i <= n; i++)
    {
        int l = i, r = a[i];

        if (l > r) swap(l, r);

        while (l >= 1 && r <= n)
        {
            mp[l][r - l + 1]++;

            int val = mp[l][r - l + 1];

            if (mx[l] == 0 || val > mp[l][mx[l]]) mx[l] = r - l + 1;

            l--; r++;
        }
    }

    int mxr = 0, l = 1, r = 1;

    for (int i = 1; i <= n; i++)
    {
        if (mxr < mp[i][mx[i]])
        {
            mxr = mp[i][mx[i]];

            l = a[i];

            r = a[i + mx[i] - 1];
        }
    }
    cout << l << " " << r << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 21 ms 27776 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 21 ms 27776 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 24 ms 28800 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 149 ms 50296 KB Output is correct
2 Correct 101 ms 44408 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 737 ms 131072 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 182 ms 28128 KB Output is correct
2 Incorrect 29 ms 29568 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Runtime error 744 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 750 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 800 ms 131072 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 746 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -