답안 #951362

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
951362 2024-03-21T17:16:48 Z nguyennh Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) C++14
17 / 100
76 ms 14160 KB
#include<bits/stdc++.h>
#define el '\n'
using namespace std ;

mt19937 rd(chrono::steady_clock::now().time_since_epoch().count());

const int MN = 1e6 + 5;

int n , m , a[MN];

namespace sub_trau{
  bool valid_input(){
    return n <= 500 && m <= 500;
  }
  
  void solve(){
    while(m--){
      int l , r , k;
      cin >> l >> r >> k;
      int ans = 0;
      for ( int i = l ; i <= r ; i++ ){
        for ( int j = i ; j <= r ; j++ ){
          if (a[j] < a[i]) ans = max(ans , a[j] + a[i]);
        }
      }
      cout << (ans <= k ? 1 : 0) << el;
    }
  }
}

namespace sub2{
  bool valid_input(){
    return n <= 5000 && m <= 5000;
  }
  
  void solve(){
    while(m--){
      int l , r , k;
      cin >> l >> r >> k;
      int ans = 0;
      vector<int> pref(r + 3);
      pref[l - 1] = INT_MIN;
      pref[l] = a[l];
      for ( int i = l + 1 ; i <= r ; i++ ) pref[i] = max(pref[i - 1] , a[i]);
      for ( int i = l ; i <= r ; i++ ){
        if (pref[i - 1] > a[i]) ans = max(ans , a[i] + pref[i - 1]);
      }
      cout << (ans <= k ? 1 : 0) << el;
    }
  }
}

int32_t main (){
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m;
  for ( int i = 1 ; i <= n ; i++ ) cin >> a[i];
  if (sub_trau::valid_input()){
    sub_trau::solve();
    return 0;
  }
  if (sub2::valid_input()){
    sub2::solve();
    return 0;
  }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 500 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 2 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 19 ms 484 KB Output is correct
7 Correct 20 ms 492 KB Output is correct
8 Correct 18 ms 348 KB Output is correct
9 Correct 6 ms 348 KB Output is correct
10 Correct 15 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 500 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 2 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 19 ms 484 KB Output is correct
7 Correct 20 ms 492 KB Output is correct
8 Correct 18 ms 348 KB Output is correct
9 Correct 6 ms 348 KB Output is correct
10 Correct 15 ms 344 KB Output is correct
11 Correct 7 ms 600 KB Output is correct
12 Correct 18 ms 616 KB Output is correct
13 Correct 23 ms 620 KB Output is correct
14 Correct 35 ms 604 KB Output is correct
15 Correct 36 ms 600 KB Output is correct
16 Correct 64 ms 616 KB Output is correct
17 Correct 56 ms 612 KB Output is correct
18 Correct 65 ms 484 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 76 ms 14160 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 3164 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 500 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 2 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 19 ms 484 KB Output is correct
7 Correct 20 ms 492 KB Output is correct
8 Correct 18 ms 348 KB Output is correct
9 Correct 6 ms 348 KB Output is correct
10 Correct 15 ms 344 KB Output is correct
11 Correct 7 ms 600 KB Output is correct
12 Correct 18 ms 616 KB Output is correct
13 Correct 23 ms 620 KB Output is correct
14 Correct 35 ms 604 KB Output is correct
15 Correct 36 ms 600 KB Output is correct
16 Correct 64 ms 616 KB Output is correct
17 Correct 56 ms 612 KB Output is correct
18 Correct 65 ms 484 KB Output is correct
19 Incorrect 16 ms 4700 KB Output isn't correct
20 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 500 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 2 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 19 ms 484 KB Output is correct
7 Correct 20 ms 492 KB Output is correct
8 Correct 18 ms 348 KB Output is correct
9 Correct 6 ms 348 KB Output is correct
10 Correct 15 ms 344 KB Output is correct
11 Correct 7 ms 600 KB Output is correct
12 Correct 18 ms 616 KB Output is correct
13 Correct 23 ms 620 KB Output is correct
14 Correct 35 ms 604 KB Output is correct
15 Correct 36 ms 600 KB Output is correct
16 Correct 64 ms 616 KB Output is correct
17 Correct 56 ms 612 KB Output is correct
18 Correct 65 ms 484 KB Output is correct
19 Incorrect 76 ms 14160 KB Output isn't correct
20 Halted 0 ms 0 KB -