146042025-01-20 14:48:05sarminRendező robot (80 pont)cpp17Elfogadva 80/80145ms11828 KiB
// Created by Armin on 1/20/2025.

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pp = pair<int, int>;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    
    int n; cin >> n;
    vector<int> v(n);
    map<int, int> where;
    for (int i = 0; i < n; i++) {
      cin >> v[i];
      where[v[i]] = i;
    }

    int current1 = n / 2 + 1;
    int next1 = current1 + 1;
    while (next1 <= n && where[current1] < where[next1]) {
      current1 = next1;
      next1++;
    }

    int current2 = n / 2 + 1;
    int next2 = current2 - 1;
	while (next2 > 0 && where[current2] > where[next2]) {
		current2 = next2;
		next2--;
	}
    cout << max((n - current1) * 2, (current2 - 1) * 2 - 1) << endl;
    
    return 0;
}
RészfeladatÖsszpontTesztVerdiktIdőMemória
base80/80
1Elfogadva0/01ms316 KiB
2Elfogadva0/01ms500 KiB
3Elfogadva2/21ms500 KiB
4Elfogadva3/31ms316 KiB
5Elfogadva3/31ms316 KiB
6Elfogadva2/22ms316 KiB
7Elfogadva2/22ms316 KiB
8Elfogadva2/21ms564 KiB
9Elfogadva2/22ms316 KiB
10Elfogadva2/22ms316 KiB
11Elfogadva2/22ms316 KiB
12Elfogadva2/22ms672 KiB
13Elfogadva2/22ms316 KiB
14Elfogadva2/22ms428 KiB
15Elfogadva2/22ms428 KiB
16Elfogadva2/22ms328 KiB
17Elfogadva2/22ms316 KiB
18Elfogadva4/4141ms11660 KiB
19Elfogadva4/4145ms11820 KiB
20Elfogadva4/4108ms11636 KiB
21Elfogadva4/486ms11828 KiB
22Elfogadva4/472ms11700 KiB
23Elfogadva4/468ms11828 KiB
24Elfogadva4/4123ms11828 KiB
25Elfogadva4/4136ms11828 KiB
26Elfogadva4/4103ms11828 KiB
27Elfogadva4/4105ms11828 KiB
28Elfogadva4/4111ms11704 KiB
29Elfogadva4/4108ms11828 KiB