답안 #988973

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
988973 2024-05-27T07:46:30 Z MercubytheFirst Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) C++17
0 / 100
3000 ms 22168 KB
#include <bits/stdc++.h>
using ll = long long;
#define pb push_back
using namespace std;
#define CDIV(a, b) ((((a) - (1)) / (b)) + 1)

void solve() { 
  int n, Q;
  cin >> n >> Q;
  vector<int> v(n + 1);
  for(int i = 1; i <= n; ++i) {
    cin >> v[i];
  }
  while(Q--) {
    int l, r, k;
    cin >> l >> r >> k;
    set<int> s;
    int mx = -1;
    for(int i = l; i <= r; ++i) {
      if(!s.empty() and *s.rbegin() > v[i]) {
        mx = max(mx, v[i] + *s.rbegin());
      }
      s.insert(v[i]);
    }
    if(mx > k) {
      cout << 0 << endl;
    }
    else {
      cout << 1 << endl;
    }
  }
}

signed main() {
  #ifndef ONLINE_JUDGE
  freopen("in.txt", "r", stdin);
  freopen("out.txt", "w", stdout);
  #endif
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  // signed t = 0; cin >> t; while(t --> 0) 
    solve();
}

Compilation message

sortbooks.cpp: In function 'int main()':
sortbooks.cpp:36:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   36 |   freopen("in.txt", "r", stdin);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
sortbooks.cpp:37:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   37 |   freopen("out.txt", "w", stdout);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3064 ms 21244 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3064 ms 21244 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3013 ms 22168 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3016 ms 22000 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3064 ms 21244 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3064 ms 21244 KB Time limit exceeded
2 Halted 0 ms 0 KB -