답안 #651231

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
651231 2022-10-18T03:18:32 Z weakweakweak Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) C++14
30 / 100
1018 ms 14556 KB
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")

const int MXN=1010000;
int n, m, o[MXN];

struct seg1{
  int a[MXN*4];
  int f(int i, int j){return min(i, j);}
  void build(int l, int r, int id){
    if(l==r){a[id]=o[l]; return;}
    int mid=(l+r)/2;
    build(l, mid, id*2); build(mid+1, r, id*2+1);
    a[id]=f(a[id*2], a[id*2+1]);}
  int query(int l, int r, int ql, int qr ,int id){
    if(ql<=l&&r<=qr)return a[id];
    int res=INT_MAX, mid=(l+r)/2;
    if(ql<=mid)res=f(res, query(l, mid, ql, qr, id*2));
    if(qr>mid)res=f(res, query(mid+1, r, ql, qr, id*2+1));
    return res;}
}s1;

int main(){
  ios_base::sync_with_stdio(false); cin.tie(0);
  cin>>n>>m;
  for(int i=1; i<=n; i++)cin>>o[i];
  if(n<=5000&&m<=5000){
    while(m--){
      int l, r, k;
      cin>>l>>r>>k;
      int mx=o[l], chk=1;
      for(int i=l; i<=r; i++){
        if(o[i]<mx&&mx+o[i]>k)chk=0;
        mx=max(mx, o[i]);}
      cout<<chk<<'\n';
    }  
  }
  else{
    for(int i=1; i<=n; i++)o[i]=o[i+1]-o[i];
    s1.build(1, n-1, 1);
    while(m--){
      int l, r, k;
      cin>>l>>r>>k;
      if(l==r){cout<<1<<'\n'; continue;}
      int x=s1.query(1, n-1, l, r-1, 1);
      if(x<0)cout<<0<<'\n';
      else cout<<1<<'\n';}
  }
return 0;}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 3 ms 340 KB Output is correct
12 Correct 5 ms 340 KB Output is correct
13 Correct 7 ms 340 KB Output is correct
14 Correct 10 ms 340 KB Output is correct
15 Correct 10 ms 340 KB Output is correct
16 Correct 20 ms 364 KB Output is correct
17 Correct 15 ms 340 KB Output is correct
18 Correct 16 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1016 ms 14552 KB Output is correct
2 Correct 948 ms 14440 KB Output is correct
3 Correct 949 ms 14556 KB Output is correct
4 Correct 1018 ms 14460 KB Output is correct
5 Correct 953 ms 14376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 71 ms 1868 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 3 ms 340 KB Output is correct
12 Correct 5 ms 340 KB Output is correct
13 Correct 7 ms 340 KB Output is correct
14 Correct 10 ms 340 KB Output is correct
15 Correct 10 ms 340 KB Output is correct
16 Correct 20 ms 364 KB Output is correct
17 Correct 15 ms 340 KB Output is correct
18 Correct 16 ms 364 KB Output is correct
19 Incorrect 181 ms 3532 KB Output isn't correct
20 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 3 ms 340 KB Output is correct
12 Correct 5 ms 340 KB Output is correct
13 Correct 7 ms 340 KB Output is correct
14 Correct 10 ms 340 KB Output is correct
15 Correct 10 ms 340 KB Output is correct
16 Correct 20 ms 364 KB Output is correct
17 Correct 15 ms 340 KB Output is correct
18 Correct 16 ms 364 KB Output is correct
19 Correct 1016 ms 14552 KB Output is correct
20 Correct 948 ms 14440 KB Output is correct
21 Correct 949 ms 14556 KB Output is correct
22 Correct 1018 ms 14460 KB Output is correct
23 Correct 953 ms 14376 KB Output is correct
24 Incorrect 71 ms 1868 KB Output isn't correct
25 Halted 0 ms 0 KB -