제출 #992764

#제출 시각아이디문제언어결과실행 시간메모리
992764danikoynovHedgehog Daniyar and Algorithms (IZhO19_sortbooks)C++14
17 / 100
3091 ms13508 KiB
#include<bits/stdc++.h> #define endl '\n' using namespace std; typedef long long ll; void speed() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); } const int maxn = 1e6 + 10; int n, m, w[maxn]; void solve() { cin >> n >> m; for (int i = 1; i <= n; i ++) { cin >> w[i]; } stack < int > st; vector < pair < int, int > > fun; for (int i = 1; i <= n; i ++) { while(!st.empty() && w[st.top()] <= w[i]) st.pop(); if (!st.empty()) { fun.push_back({st.top(), i}); } st.push(i); } for (int i = 1; i <= m; i ++) { int l, r, k; cin >> l >> r >> k; int mx = 0; for (pair < int, int > cur : fun) { if (cur.first >= l && cur.second <= r) mx = max(mx, w[cur.first] + w[cur.second]); } cout << (mx <= k) << endl; } } int main() { speed(); solve(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...