250662026-02-17 18:57:48sarminRendező robot (80 pont)cpp17Wrong answer 14/8028ms2004 KiB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
// const ll MOD = 1e9+7;

#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n; cin >> n;
    vector<int> pos(n);
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
    	cin >> a[i];
    	pos[a[i]] = i;
    }
    
    int mn = INT_MAX;
    int start = 1;
    for (int i = 2; i <= n; i++) {
    	if (pos[i-1] > pos[i]) {
    		int x = start-1, y = n-i;
    		mn = min(mn, max(max(0, 2*x-1), 2*y));
    		start = i;
    	}
    }
    int x = start-1, y = 0;
    mn = min(mn, max(max(0, 2*x-1), 2*y));
    cout << mn << "\n";
    
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base14/80
1Accepted0/01ms316 KiB
2Accepted0/01ms316 KiB
3Accepted2/21ms332 KiB
4Wrong answer0/31ms316 KiB
5Wrong answer0/31ms316 KiB
6Wrong answer0/21ms316 KiB
7Accepted2/21ms316 KiB
8Accepted2/21ms316 KiB
9Accepted2/21ms332 KiB
10Accepted2/21ms316 KiB
11Wrong answer0/21ms316 KiB
12Wrong answer0/21ms316 KiB
13Wrong answer0/21ms316 KiB
14Wrong answer0/21ms316 KiB
15Wrong answer0/21ms316 KiB
16Wrong answer0/21ms508 KiB
17Wrong answer0/21ms316 KiB
18Accepted4/428ms1996 KiB
19Wrong answer0/428ms1844 KiB
20Wrong answer0/425ms1848 KiB
21Wrong answer0/425ms1844 KiB
22Wrong answer0/426ms2004 KiB
23Wrong answer0/425ms1844 KiB
24Wrong answer0/426ms1844 KiB
25Wrong answer0/426ms1844 KiB
26Wrong answer0/426ms1844 KiB
27Wrong answer0/427ms2004 KiB
28Wrong answer0/426ms1844 KiB
29Wrong answer0/425ms1844 KiB