/ SeriousOJ /

Record Detail

Time Exceeded


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 492.0 KiB
#2 Accepted 1ms 324.0 KiB
#3 Time Exceeded ≥2065ms ≥1.32 MiB
#4 Accepted 62ms 1.527 MiB
#5 Accepted 61ms 1.57 MiB
#6 Accepted 71ms 1.547 MiB
#7 Accepted 1ms 320.0 KiB
#8 Accepted 1ms 324.0 KiB
#9 Accepted 81ms 1.914 MiB
#10 Accepted 74ms 1.496 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-11-11 03:07:52
Judged By
Score
90
Total Time
≥2065ms
Peak Memory
≥1.914 MiB