Submission #1115631

#TimeUsernameProblemLanguageResultExecution timeMemory
1115631vjudge1Hedgehog Daniyar and Algorithms (IZhO19_sortbooks)C++17
17 / 100
278 ms63364 KiB
#include <bits/stdc++.h> #define ll long long #define pb push_back #define pf push_front #define F first #define S second #define all(v) (v).begin(),(v).end() #define int long long using namespace std; const int maxn = 1e6 + 5; const int mod = 1e9 + 7; int n,a[maxn],m,b[maxn],c[maxn],d[maxn]; void webbly_abi_spasibo(){ cin >> n >> m; for(int i = 1; i <= n; i++){ cin >> a[i]; } for(int i = 1; i <= m; i++){ cin >> b[i] >> c[i] >> d[i]; } if(n <= 5000 && m <= 5000){ for(int i = 1; i <= m; i++){ int l = b[i], r = c[i], val = d[i]; int mx = a[l]; bool ok = 1; for(int j = l + 1; j <= r; j++){ if(mx > a[j]){ if(mx + a[j] > val) { ok = 0; break; } } mx = max(mx, a[j]); } cout << ok << '\n'; } } } signed main(){ // // freopen("greedy.in", "r", stdin); // freopen("greedy.out", "w", stdout); ios_base::sync_with_stdio(0); cin.tie(0); int tt = 1; //cin >> tt; while(tt--){ webbly_abi_spasibo(); } 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...