Submission #473210

# Submission time Handle Problem Language Result Execution time Memory
473210 2021-09-15T10:21:15 Z _L__ Doktor (COCI17_doktor) C++17
30 / 100
1000 ms 4044 KB
// This code is written by _L__
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define F_word ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
typedef long long ll;
typedef long double ld;
const int mod = 1e9+7, N = 2e5+13, inf = 1e9+1;
const ld E = 1e-6;
#define ff first
#define ss second

int main(void){
    F_word;
    int n; cin >> n;
    int sum = 0, ans1 = 1, ans2 = 1;
    int a[n+2] = {}, doc[n+4] = {}; for(int i = 1; i <= n; ++i){cin >> a[i]; doc[a[i]] = a[i]-i;}
    for(int i = 1; i <= n; ++i){
        for(int j = i; j <= n; ++j){
            reverse(a+i, a+j+1);
            ll x = 0; for(int k = 1; k <= n; ++k) x += (a[k] == k);
            if(x >= sum){
                ans1 = i, ans2 = j, sum = x;
            }
            reverse(a+i, a+j+1);
        }
    }
    cout << a[ans1] << ' ' << a[ans2] << endl;
} 
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 22 ms 308 KB Output is correct
2 Correct 39 ms 288 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1083 ms 204 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1091 ms 332 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1090 ms 332 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1086 ms 332 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1095 ms 972 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1091 ms 4044 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1087 ms 2508 KB Time limit exceeded
2 Halted 0 ms 0 KB -