/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 532.0 KiB
#2 Wrong Answer 1ms 532.0 KiB
#3 Accepted 63ms 1.871 MiB
#4 Accepted 141ms 4.441 MiB
#5 Accepted 90ms 3.906 MiB
#6 Accepted 62ms 1.379 MiB
#7 Accepted 2ms 532.0 KiB
#8 Wrong Answer 2ms 552.0 KiB
#9 Wrong Answer 166ms 4.855 MiB
#10 Wrong Answer 215ms 6.18 MiB

Code

// @sagorahmedmunna

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

const int INF = 1.1e9;

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  
  int n;
  cin >> n;
  vector<int> a(n + 2);
  a[n + 1] = INF;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  set<int> st = {INF};
  for (int i = 1; i < n; i++) {
    if (a[i] > a[i + 1]) {
      st.insert(i + 1);
    }
  }
  int q;
  cin >> q;
  while (q--) {
    int type;
    cin >> type;
    if (type == 1) {
      int i, x;
      cin >> i >> x;
      a[i] = x;
      if (a[i] > a[i + 1]) st.insert(i + 1);
      else st.erase(i + 1);
      if (a[i - 1] > a[i]) st.insert(i);
      else st.erase(i);
    } else {
      int l, r;
      cin >> l >> r;
      auto up = st.upper_bound(l + 1);
      cout << (*up > r ? "YES" : "NO") << '\n';
    }
  }
  return 0;
}

Information

Submit By
Type
Submission
Problem
P1085 Sorted or !Sorted
Contest
Bangladesh 2.0
Language
C++20 (G++ 13.2.0)
Submit At
2024-08-16 16:58:51
Judged At
2024-10-03 13:24:42
Judged By
Score
60
Total Time
215ms
Peak Memory
6.18 MiB