21282022-12-21 08:54:54samatInverziócpp11Wrong answer 5/50181ms7912 KiB
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main() {
  // Bemenet olvasása
  int n;
  cin >> n;

  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }

  // Keresés a maximális távolságú inverzióra
  int max_distance = 0;
  pair<int, int> max_inversion;
  int min_so_far = a[n-1];
  for (int i = n-2; i >= 0; i--) {
    if (a[i] > min_so_far) {
      int distance = n - 1 - i;
      if (distance > max_distance) {
        max_distance = distance;
        max_inversion = {i, n-1};
      }
    }
    min_so_far = min(min_so_far, a[i]);
  }

  // Kimenet írása
  if (max_distance == 0) {
    cout << -1 << endl;
  } else {
    cout << max_inversion.first+1 << " " << max_inversion.second+1 << endl;
  }

  return 0;
}
SubtaskSumTestVerdictTimeMemory
base5/50
1Accepted0/03ms1812 KiB
2Wrong answer0/017ms2372 KiB
3Accepted1/12ms2348 KiB
4Accepted2/22ms2428 KiB
5Wrong answer0/72ms2316 KiB
6Wrong answer0/217ms2580 KiB
7Wrong answer0/2173ms6508 KiB
8Wrong answer0/2173ms6668 KiB
9Wrong answer0/2172ms6872 KiB
10Wrong answer0/2173ms7188 KiB
11Wrong answer0/2172ms7396 KiB
12Wrong answer0/2171ms6968 KiB
13Wrong answer0/2173ms7232 KiB
14Wrong answer0/2173ms7484 KiB
15Wrong answer0/2173ms7432 KiB
16Wrong answer0/2173ms7436 KiB
17Wrong answer0/2173ms7432 KiB
18Wrong answer0/2173ms7756 KiB
19Wrong answer0/3173ms7636 KiB
20Wrong answer0/3181ms7640 KiB
21Wrong answer0/2173ms7892 KiB
22Wrong answer0/2173ms7844 KiB
23Wrong answer0/2173ms7912 KiB
24Accepted2/2173ms7840 KiB