/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 532.0 KiB
#2 Accepted 1ms 532.0 KiB
#3 Accepted 1ms 532.0 KiB
#4 Wrong Answer 1ms 532.0 KiB
#5 Accepted 1ms 532.0 KiB
#6 Wrong Answer 1ms 320.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;
        l = i;
        break;
      }
    }
    for (int i = n - 1; i >= 0; i--){
      if (a[i] != b[i]){
        r = i;
        break;
      }
    }
    if (ok){
      cout << "YES\n0 0\n";
    } else if (l == -1 || r - l + 1 > k){
      cout << "NO" << endl;
    } else {
      cout << "YES\n" << l + 1 << " " << r + 1 << 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:18:49
Judged At
2024-11-05 15:18:49
Judged By
Score
9
Total Time
1ms
Peak Memory
532.0 KiB