/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 320.0 KiB
#2 Accepted 1ms 328.0 KiB
#3 Accepted 1ms 324.0 KiB
#4 Wrong Answer 1ms 488.0 KiB
#5 Accepted 1ms 320.0 KiB
#6 Wrong Answer 1ms 324.0 KiB

Code

#include<bits/stdc++.h>
#define ll long long
using namespace std;

int main() {
  /*int t;
  cin >> t;
  while (t--){*/
    ll n, k, l = -1, r = -1;
    cin >> n >> k;
    set<int> s;
    vector<int> a(n), b(n);
    for (int i = 0; i < n; i++){
      cin >> a[i];
      s.insert(a[i]);
      b[i] = a[i];
    }
    if (s.size() != n){
      cout << "NO" << endl;
      return 0;
    }
    sort(b.begin(), b.end());
    int ok = 1;
    for (int i = 0; i < n; i++){
      if (a[i] != b[i]){
        ok = 0;
        if (l == -1) l = i + 1;
        int j = i;
        while (j < n && a[j] != b[j]) j++;
        //if (j == n) l = -1;
        r = j;
        for (int q = j; q < n; q++){
          if (a[q] != b[q]) r = q + 1;
        }
        break;
      }
    }
    if (ok){
      cout << "YES\n1 1" << endl;
      return 0;
    }
    if (l == -1 || r - l + 1 > k){
      cout << "NO" << endl;
    } else {
      cout << "YES\n" << l << " " << r << endl;
    }
    return 0;
}

Information

Submit By
Type
Submission
Problem
P1120 Stairway to the Skyline
Contest
Brain Booster #7
Language
C++17 (G++ 13.2.0)
Submit At
2024-11-05 15:12:09
Judged At
2024-11-11 02:31:14
Judged By
Score
9
Total Time
1ms
Peak Memory
488.0 KiB