/ SeriousOJ /

Record Detail

Time Exceeded


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 532.0 KiB
#2 Accepted 1ms 532.0 KiB
#3 Time Exceeded ≥2100ms ≥1.312 MiB
#4 Accepted 53ms 1.52 MiB
#5 Accepted 52ms 1.52 MiB
#6 Accepted 59ms 1.52 MiB
#7 Accepted 1ms 532.0 KiB
#8 Accepted 1ms 532.0 KiB
#9 Accepted 65ms 1.773 MiB
#10 Accepted 71ms 1.52 MiB

Code

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N = 2e5 + 10;
const ll MOD = 1e9 + 7;

bool ans = true;
void mergeSort(vector<int> &v, int low, int high) {
  if(low >= high) return;
  int mid = low + (high - low) / 2;
  ans &= (v[mid] <= v[mid + 1]);
  if(ans) mergeSort(v, low, mid);
  if(ans) mergeSort(v, mid + 1, high);
}

void solve()
{
  int n;
  cin >> n;
  
  vector<int> v(n);
  for(int i = 0; i < n; i++) {
    cin >> v[i];
  }
  
  int q;
  cin >> q;
  while(q--) {
    int type, a, b;
    cin >> type >> a >> b;
    a--, b--;
    if(type == 1) v[a] = b + 1;
    else {
      ans = true;
      mergeSort(v, a, b);
      if(ans) cout << "YES" << "\n";
      else cout << "NO" << "\n";
    }
  }
}

int main()
{
  ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
  solve();
}

Information

Submit By
Type
Submission
Problem
P1085 Sorted or !Sorted
Language
C++20 (G++ 13.2.0)
Submit At
2024-08-18 09:18:15
Judged At
2024-08-18 09:18:15
Judged By
Score
90
Total Time
≥2100ms
Peak Memory
≥1.773 MiB