/ 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 ≥2001ms ≥2.062 MiB
#4 Accepted 53ms 2.27 MiB
#5 Accepted 52ms 2.32 MiB
#6 Accepted 60ms 2.27 MiB
#7 Accepted 1ms 320.0 KiB
#8 Accepted 1ms 532.0 KiB
#9 Accepted 65ms 2.52 MiB
#10 Accepted 70ms 2.27 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<ll> &v, ll low, ll high) {
  if(low >= high) return;
  ll 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()
{
  ll n;
  cin >> n;
  
  vector<ll> v(n);
  for(ll i = 0; i < n; i++) {
    cin >> v[i];
  }
  
  ll q;
  cin >> q;
  while(q--) {
    ll 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:16:52
Judged At
2024-08-18 09:16:52
Judged By
Score
90
Total Time
≥2001ms
Peak Memory
≥2.52 MiB