Submission #1115638

#TimeUsernameProblemLanguageResultExecution timeMemory
1115638vjudge1Hedgehog Daniyar and Algorithms (IZhO19_sortbooks)C++17
17 / 100
549 ms33756 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],e[maxn],t[maxn * 4]; void build(int v = 1, int tl = 1, int tr = n){ if(tl == tr){ t[v] = a[tl]; return; } int tm = (tl + tr) >> 1; build(v + v, tl, tm); build(v + v + 1, tm + 1, tr); t[v] = min(t[v + v], t[v + v + 1]); } int get(int l, int r, int v = 1, int tl = 1, int tr = n){ if(tl > r || l > tr) return 1000000000; if(l <= tl && tr <= r) { return t[v]; } int tm = (tl + tr) >> 1; return min(get(l,r,v+v,tl,tm), get(l,r,v+v+1,tm+1,tr)); } void webbly_abi_spasibo(){ cin >> n >> m; for(int i = 1; i <= n; i++){ cin >> a[i]; } bool ok1 = 1; for(int i = 1; i <= m; i++){ cin >> b[i] >> c[i] >> d[i]; if(d[i] >= get(b[i],c[i])) ok1 = 0; } 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'; } } else if(ok1){ for(int i = 2; i <= n; i++){ if(a[i] < a[i - 1]){ e[i] = 1; } e[i] += e[i-1]; } for(int i = 1; i <= m; i++){ int l = b[i], r = c[i], val = d[i]; if(e[r] - e[l-1]){ cout << "0\n"; } else { cout << "1\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; }

Compilation message (stderr)

sortbooks.cpp: In function 'void webbly_abi_spasibo()':
sortbooks.cpp:90:28: warning: unused variable 'val' [-Wunused-variable]
   90 |    int l = b[i], r = c[i], val = d[i];
      |                            ^~~
#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...