// Problem: E - Hedgehog Daniyar and Algorithms
// Contest: Virtual Judge - Selection
// URL: https://vjudge.net/contest/673521#problem/E
// Memory Limit: 256 MB
// Time Limit: 3000 ms
//
// Powered by CP Editor (https://cpeditor.org)
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// Solution
// Webbly, 27.01.2023
//
//
// Arsen ne katai
//
//
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#include<bits/stdc++.h>
/**
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <map>
#include <set>
#include <time.h>
*/
//#pragma GCC optimize("O3")
//#pragma GCC optimize("fast-loops")
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
/**
#pragma GCC optimize("-funsafe-loop-optimizations")
#pragma GCC optimize("-funroll-loops")
#pragma GCC optimize("-fwhole-program")
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC optimize("-fthread-jumps")
#pragma GCC optimize("-falign-functions")
#pragma GCC optimize("-falign-jumps")
#pragma GCC optimize("-falign-loops")
#pragma GCC optimize("-falign-labels")
#pragma GCC optimize("-fcaller-saves")
#pragma GCC optimize("-fcrossjumping")
#pragma GCC optimize("-fcse-follow-jumps")
#pragma GCC optimize("-fcse-skip-blocks")
#pragma GCC optimize("-fdelete-null-pointer-checks")
#pragma GCC optimize("-fdevirtualize")
#pragma GCC optimize("-fexpensive-optimizations")
#pragma GCC optimize("-fgcse")
#pragma GCC optimize("-fgcse-lm")
#pragma GCC optimize("-fhoist-adjacent-loads")
#pragma GCC optimize("-finline-small-functions")
#pragma GCC optimize("-findirect-inlining")
#pragma GCC optimize("-fipa-sra")
#pragma GCC optimize("-foptimize-sibling-calls")
#pragma GCC optimize("-fpartial-inlining")
#pragma GCC optimize("-fpeephole2")
#pragma GCC optimize("-freorder-blocks")
#pragma GCC optimize("-freorder-functions")
#pragma GCC optimize("-frerun-cse-after-loop")
#pragma GCC optimize("-fsched-interblock")
#pragma GCC optimize("-fsched-spec")
#pragma GCC optimize("-fschedule-insns")
#pragma GCC optimize("-fschedule-insns2")
#pragma GCC optimize("-fstrict-aliasing")
#pragma GCC optimize("-fstrict-overflow")
#pragma GCC optimize("-ftree-switch-conversion")
#pragma GCC optimize("-ftree-tail-merge")
#pragma GCC optimize("-ftree-pre")
#pragma GCC optimize("-ftree-vrp")
#pragma GCC target("avx")
*/
#define ll long long
#define kebzaro ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define flush cout.flush()
using namespace std;
const ll mod = (ll)1e9 + 7, mod3 = 998244353, inf = (ll)2e15, P = 31;
void judge(string name){
if (name.size()){
freopen((name + ".in").c_str(), "r", stdin);
freopen((name + "out").c_str(), "w", stdout);
}
}
ll rnd(){
ll x = rand();
return rand() ^ x;
}
ll binpow (ll a, ll b){
ll ans = 1;
while(b){
if (b & 1){
ans *= a;
ans %= mod;
}
b >>= 1;
a *= a;
a %= mod;
}
return ans;
}
ll gcd(ll a, ll b){
return (b ? gcd(b, a % b) : a);
}
ll lcm(ll a, ll b){
return a / gcd(a, b) * b;
}
struct tr{
ll four, seven, inc, dec;
};
struct T{
ll l, r, val, ind;
};
ll n, m, k, a[1000005], b[1000005], p[500005];
string s;
void sarsen(){
cin >> n >> k;
for (ll i = 1; i <= n; i++){
cin >> a[i];
}
for (ll i = 1, l, r, mood; i <= k; i++){
cin >> l >> r >> mood;
ll mn = 0;
bool check = 1;
for (ll j = l; j <= r; j++){
if (a[j] < mn && mn + a[j] > mood) check = 0;
mn = max(mn, a[j]);
}
if (check) cout << "1\n";
else cout << "0\n";
}
}
int main(){
kebzaro
judge("");
ll TT = 1, tests = 1;
//cin >> TT;
while(TT--){
//cout << "Case " << tests << ": ";
sarsen();
//tests++;
}
return 0;
}
/**
*/
Compilation message
sortbooks.cpp: In function 'int main()':
sortbooks.cpp:172:16: warning: unused variable 'tests' [-Wunused-variable]
172 | ll TT = 1, tests = 1;
| ^~~~~
sortbooks.cpp: In function 'void judge(std::string)':
sortbooks.cpp:95:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
95 | freopen((name + ".in").c_str(), "r", stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
sortbooks.cpp:96:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
96 | freopen((name + "out").c_str(), "w", stdout);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2384 KB |
Output is correct |
2 |
Correct |
1 ms |
2384 KB |
Output is correct |
3 |
Correct |
1 ms |
2384 KB |
Output is correct |
4 |
Correct |
1 ms |
2384 KB |
Output is correct |
5 |
Correct |
1 ms |
2384 KB |
Output is correct |
6 |
Correct |
1 ms |
2384 KB |
Output is correct |
7 |
Correct |
1 ms |
2384 KB |
Output is correct |
8 |
Correct |
1 ms |
2556 KB |
Output is correct |
9 |
Correct |
1 ms |
2384 KB |
Output is correct |
10 |
Correct |
1 ms |
2552 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2384 KB |
Output is correct |
2 |
Correct |
1 ms |
2384 KB |
Output is correct |
3 |
Correct |
1 ms |
2384 KB |
Output is correct |
4 |
Correct |
1 ms |
2384 KB |
Output is correct |
5 |
Correct |
1 ms |
2384 KB |
Output is correct |
6 |
Correct |
1 ms |
2384 KB |
Output is correct |
7 |
Correct |
1 ms |
2384 KB |
Output is correct |
8 |
Correct |
1 ms |
2556 KB |
Output is correct |
9 |
Correct |
1 ms |
2384 KB |
Output is correct |
10 |
Correct |
1 ms |
2552 KB |
Output is correct |
11 |
Correct |
3 ms |
2552 KB |
Output is correct |
12 |
Correct |
5 ms |
2384 KB |
Output is correct |
13 |
Correct |
5 ms |
2628 KB |
Output is correct |
14 |
Correct |
8 ms |
2640 KB |
Output is correct |
15 |
Correct |
8 ms |
2640 KB |
Output is correct |
16 |
Correct |
14 ms |
2640 KB |
Output is correct |
17 |
Correct |
11 ms |
2384 KB |
Output is correct |
18 |
Correct |
12 ms |
2384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
3034 ms |
19688 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1645 ms |
6852 KB |
Output is correct |
2 |
Execution timed out |
3057 ms |
5848 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2384 KB |
Output is correct |
2 |
Correct |
1 ms |
2384 KB |
Output is correct |
3 |
Correct |
1 ms |
2384 KB |
Output is correct |
4 |
Correct |
1 ms |
2384 KB |
Output is correct |
5 |
Correct |
1 ms |
2384 KB |
Output is correct |
6 |
Correct |
1 ms |
2384 KB |
Output is correct |
7 |
Correct |
1 ms |
2384 KB |
Output is correct |
8 |
Correct |
1 ms |
2556 KB |
Output is correct |
9 |
Correct |
1 ms |
2384 KB |
Output is correct |
10 |
Correct |
1 ms |
2552 KB |
Output is correct |
11 |
Correct |
3 ms |
2552 KB |
Output is correct |
12 |
Correct |
5 ms |
2384 KB |
Output is correct |
13 |
Correct |
5 ms |
2628 KB |
Output is correct |
14 |
Correct |
8 ms |
2640 KB |
Output is correct |
15 |
Correct |
8 ms |
2640 KB |
Output is correct |
16 |
Correct |
14 ms |
2640 KB |
Output is correct |
17 |
Correct |
11 ms |
2384 KB |
Output is correct |
18 |
Correct |
12 ms |
2384 KB |
Output is correct |
19 |
Execution timed out |
3060 ms |
8916 KB |
Time limit exceeded |
20 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2384 KB |
Output is correct |
2 |
Correct |
1 ms |
2384 KB |
Output is correct |
3 |
Correct |
1 ms |
2384 KB |
Output is correct |
4 |
Correct |
1 ms |
2384 KB |
Output is correct |
5 |
Correct |
1 ms |
2384 KB |
Output is correct |
6 |
Correct |
1 ms |
2384 KB |
Output is correct |
7 |
Correct |
1 ms |
2384 KB |
Output is correct |
8 |
Correct |
1 ms |
2556 KB |
Output is correct |
9 |
Correct |
1 ms |
2384 KB |
Output is correct |
10 |
Correct |
1 ms |
2552 KB |
Output is correct |
11 |
Correct |
3 ms |
2552 KB |
Output is correct |
12 |
Correct |
5 ms |
2384 KB |
Output is correct |
13 |
Correct |
5 ms |
2628 KB |
Output is correct |
14 |
Correct |
8 ms |
2640 KB |
Output is correct |
15 |
Correct |
8 ms |
2640 KB |
Output is correct |
16 |
Correct |
14 ms |
2640 KB |
Output is correct |
17 |
Correct |
11 ms |
2384 KB |
Output is correct |
18 |
Correct |
12 ms |
2384 KB |
Output is correct |
19 |
Execution timed out |
3034 ms |
19688 KB |
Time limit exceeded |
20 |
Halted |
0 ms |
0 KB |
- |