Submission #1092913

#TimeUsernameProblemLanguageResultExecution timeMemory
1092913NurislamHedgehog Daniyar and Algorithms (IZhO19_sortbooks)C++17
17 / 100
3059 ms33808 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #include <ext/pb_ds/detail/standard_policies.hpp> using namespace __gnu_pbds; using namespace std; #define pb push_back #define ff first #define ss second #define all(x) x.begin(),x.end() #define rall(x) x.rbegin(),x.rend() #define int long long template <class F, class _S> bool chmin(F &u, const _S &v){ bool flag = false; if ( u > v ){ u = v; flag |= true; } return flag; } template <class F, class _S> bool chmax(F &u, const _S &v){ bool flag = false; if ( u < v ){ u = v; flag |= true; } return flag; } const int N = 1e5+50, inf = 1e18+200; //int mod = 998244353; //int mod = 1000000007; //mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); //#define rnd(l, r) uniform_int_distribution <int> (l, r)(rng) void solve(){ auto calc = [&](vector<int> a) -> int{ int sz = a.size(), ans = 0; for(int i = 0; i < sz; i++){ for(int j = i-1; j >= 0; j--){ if(a[i] < a[j])swap(a[i], a[j]), chmax(ans, a[i] + a[j]); else break; } } return ans; }; int n, q; cin >> n >> q; vector<int> a(n+1); for(int i = 1; i <= n; i++)cin >> a[i]; while(q--){ int l, r, k; cin >> l >> r >> k; vector<int> res; for(int i = l; i <= r; i++)res.pb(a[i]); int ans = calc(res); //cout << ans << '\n'; cout << (ans <= k) << '\n'; } } signed main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); int tt = 1; //cin >> tt; while(tt--){ solve(); } }
#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...