/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 2ms 540.0 KiB
#2 Accepted 2ms 560.0 KiB
#3 Accepted 2ms 540.0 KiB
#4 Accepted 2ms 500.0 KiB
#5 Accepted 2ms 332.0 KiB
#6 Accepted 2ms 328.0 KiB
#7 Accepted 3ms 332.0 KiB
#8 Accepted 2ms 512.0 KiB
#9 Accepted 2ms 332.0 KiB
#10 Accepted 2ms 328.0 KiB
#11 Accepted 2ms 332.0 KiB
#12 Accepted 2ms 328.0 KiB
#13 Accepted 2ms 328.0 KiB
#14 Accepted 2ms 588.0 KiB
#15 Accepted 2ms 528.0 KiB
#16 Accepted 2ms 584.0 KiB
#17 Accepted 2ms 592.0 KiB
#18 Accepted 2ms 512.0 KiB
#19 Accepted 2ms 332.0 KiB
#20 Accepted 2ms 328.0 KiB
#21 Accepted 9ms 836.0 KiB
#22 Accepted 119ms 4.844 MiB
#23 Accepted 127ms 5.359 MiB
#24 Accepted 152ms 6.578 MiB
#25 Accepted 286ms 9.762 MiB
#26 Accepted 105ms 5.039 MiB
#27 Accepted 18ms 1.234 MiB
#28 Accepted 139ms 5.258 MiB
#29 Accepted 153ms 6.031 MiB
#30 Accepted 220ms 9.898 MiB
#31 Accepted 257ms 7.801 MiB
#32 Accepted 228ms 10.328 MiB
#33 Accepted 185ms 8.391 MiB
#34 Accepted 181ms 6.512 MiB
#35 Accepted 242ms 11.082 MiB

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:20:26
Judged At
2024-11-11 02:30:53
Judged By
Score
100
Total Time
286ms
Peak Memory
11.082 MiB