Submission #895077

#TimeUsernameProblemLanguageResultExecution timeMemory
895077vjudge1Hedgehog Daniyar and Algorithms (IZhO19_sortbooks)C++17
0 / 100
3034 ms8260 KiB
//GOAL : BECOME A MASTER //cf : Mali //Toktarbek Muhammedali 10B //Esyk BIL // #include <bits/stdc++.h> #include <map> #include <set> #include <list> #include <cmath> #include <ctime> #include <deque> #include <queue> #include <stack> #include <string> #include <bitset> #include <cstdio> #include <limits> #include <vector> #include <climits> #include <cstring> #include <cstdlib> #include <fstream> #include <numeric> #include <sstream> #include <cassert> #include <iomanip> #include <iostream> #include <algorithm> #include <stdio.h> #include <fstream> using namespace std; #define fast() ios_base::sync_with_stdio(0),cin.tie(0) #define int long long #define F first #define S second const int N = 1e6 + 17; const long long INF = 1e18 + 1; const int mod = 1e9; using namespace std; int a[N]; // int b[N]; // int c[N]; // int t[4*N]; // pair<int , int> d[4*N]; int llmax(int a, int b){ if (a > b)return a; else return b; } // void build(int v, int tl , int tr){ // if (tl == tr){ // t[v] = a[tl]; // // d[v] = {b[tl] , tl}; // return; // } // int md = (tl + tr) / 2; // build(v+v , tl , md) , build(v+v+1 , md+1 , tr); // t[v] = max(t[v+v] , t[v+v+1]); // // d[v] = max(d[v+v] , d[v+v+1]); // } // int g1(int v , int tl , int tr , int l , int r){ // if (r < tl || tr < l)return -2; // if (l <= tl && tr <= r)return t[v]; // int md = (tl + tr) / 2; // return max(g1(v+v , tl , md , l , r) , g1(v+v , md+1 , tr , l , r)); // } // pair<int , int> g2(int v , int tl , int tr , int l , int r){ // if (r < tl || tr < l)return {-2 , -2}; // if (l <= tl && tr <= r)return d[v]; // int md = (tl + tr) / 2; // return max(g2(v+v , tl , md , l , r) , g2(v+v , md+1 , tr , l , r)); // } void goat(){ int n , q; cin >> n >> q; for (int i = 1 ; i <= n ; i ++)cin >> a[i]; for (int i = 1 ; i <= q ; i ++){ int l , r , x; cin >> l >> r >> x; int ans = 0 , mx = a[l]; for (int j = l+1 ; j <= r ; j ++){ if (a[j] < a[j-1]){ ans = llmax(ans , a[j] + mx); }else { mx = max(mx , a[j]); } } if (mx <= x)cout << 1 << endl; else cout << 0 << endl; } } signed main () { fast(); // freopen("B.in", "r", stdin); // freopen("B.out", "w", stdout); // int T; // cin >> T; // for (int i = 1 ; i <= T ; i ++){ goat(); // } }
#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...