제출 #241553

#제출 시각아이디문제언어결과실행 시간메모리
241553valerikkHedgehog Daniyar and Algorithms (IZhO19_sortbooks)C++17
17 / 100
3080 ms30088 KiB
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; // typedef double ld; typedef vector<int> vi; typedef vector<vi> vvi; typedef vector<ll> vl; typedef vector<vl> vvl; typedef vector<ld> vd; typedef vector<vd> vvd; typedef complex<ld> cd; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef pair<ld, ld> pdd; typedef vector<char> vc; typedef vector<vc> vvc; typedef string str; #define int ll template<class A, class B> inline bool mmin(A& a, B b) { if (b < a) { a = b; return 1; } return 0; } template<class A, class B> inline bool mmax(A& a, B b) { if (b > a) { a = b; return 1; } return 0; } ld nxt_ld() { string s; cin >> s; return stold(s); } #define x first #define y second #define pb push_back #define eb emplace_back #define pf push_front #define ef emplace_front #define ppb pop_back #define ppf pop_front #define sz(a) (int)(a).size() #define all(a) (a).begin(), (a).end() #define rall(a) (a).rbegin(), (a).rend() signed main() { /*freopen("cbarn.in", "r", stdin); freopen("cbran.out", "w", stdout);*/ ios::sync_with_stdio(false); cin.tie(0); int n, m; cin >> n >> m; vi w(n); for (int i = 0; i < n; i++) cin >> w[i]; while (m--) { int l, r, k; cin >> l >> r >> k; l--; r--; vector<int> st; bool ok = 1; for (int i = r; i >= l; i--) { while (!st.empty() && st.back() < w[i]) { if (w[i] + st.back() > k) { ok = 0; break; } st.pop_back(); } st.pb(w[i]); } cout << ok << '\n'; } 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...