21452022-12-25 10:18:21samatInverziócpp11Wrong answer 1/50326ms11288 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;
  vector<int> sorted(a);
  sort(sorted.begin(), sorted.end());
  for (int i = 0; i < n; i++) {
    int j = lower_bound(sorted.begin(), sorted.end(), a[i]) - sorted.begin();
    int distance = n - j - 1;
    if (distance > max_distance) {
      max_distance = distance;
      max_inversion = {i, n-1};
    }
  }

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

  return 0;
}
SubtaskSumTestVerdictTimeMemory
base1/50
1Wrong answer0/03ms1680 KiB
2Wrong answer0/023ms2632 KiB
3Accepted1/12ms2012 KiB
4Wrong answer0/23ms2140 KiB
5Wrong answer0/72ms2304 KiB
6Wrong answer0/228ms3200 KiB
7Wrong answer0/2224ms10700 KiB
8Wrong answer0/2324ms10552 KiB
9Wrong answer0/2326ms10444 KiB
10Wrong answer0/2305ms10476 KiB
11Wrong answer0/2305ms10672 KiB
12Wrong answer0/2300ms10620 KiB
13Wrong answer0/2305ms10872 KiB
14Wrong answer0/2307ms11080 KiB
15Wrong answer0/2225ms11008 KiB
16Wrong answer0/2307ms11288 KiB
17Wrong answer0/2307ms11208 KiB
18Wrong answer0/2307ms11240 KiB
19Wrong answer0/3225ms11208 KiB
20Wrong answer0/3225ms11212 KiB
21Wrong answer0/2224ms11212 KiB
22Wrong answer0/2305ms11212 KiB
23Wrong answer0/2307ms11212 KiB
24Wrong answer0/2216ms11208 KiB