Submission #500062

#TimeUsernameProblemLanguageResultExecution timeMemory
500062yahyobekabdunazarovHedgehog Daniyar and Algorithms (IZhO19_sortbooks)C++17
17 / 100
3087 ms22772 KiB
#include <bits/stdc++.h> #define fcc ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); #define sqr(a) (a) * (a) #define all(x) x.begin(), x.end() #define rall(x) x.rebgin(), x.rend() #define pb push_back #define mp make_pair #define int long long #define ff first #define ss second using namespace std; typedef long double ld; typedef pair<int,int> pii; typedef vector<int> vi; typedef set<int> si; int a[500009], b[500009]; void solve() { int n, m, l, r, k; cin >> n >> m; int a[n + 1]; for (int i = 1; i <= n; i++) { cin >> a[i]; } a[0] = 0; while (m--) { cin >> l >> r >> k; int ans = 0, leftmax = 0; for (int i = l; i <= r; i++) { if(ans>k){ break; } if (leftmax > a[i]) { ans = max(ans, leftmax + a[i]); } leftmax = max(leftmax, a[i]); } if (ans <= k) { cout << "1\n"; } else { cout << "0\n"; } } } signed main() { fcc; int t = 1; // cin >> t; while (t--) { solve(); cout << endl; } }
#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...