이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
#define INF 1000000021
#define pb push_back
#define sqr(a) (a)*(a)
#define M(a, b) make_pair(a,b)
#define F first
#define S second
#define all(x) (x.begin(), x.end())
#define deb(x) cerr << #x << " = " << x << '\n'
#define N 322222
using namespace std;
//using namespace __gnu_pbds;
typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
const ll MOD = 1000000007ll;
ll bn(ll aa, ll n)
{
ll r = 1ll;
for(; n > 0; n >>= 1ll)
{
if(n & 1)
r = (r * aa) % MOD;
aa = (aa * aa) % MOD;
}
return r;
}
const ld pi = 2 * acos(0.0);
//template<class T, class TT> bool pal(T a, TT n){int k=0;for(int i=0;i<=n/2;i++){if(a[i]!=a[n-i-1]){k=1;break;}}return k?0:1;}
//int month[] = {0,31,28,31,30,31,30,31,31,30,31,30,31};
/*
m/2 + 1
5 5
1 +++--
2 +++--
3 +++--
4 +++--
5 +++--
12
1 -++--++
2 --++-++
3 ---++++
4 ---++++
5 +---+++
6 ++---++
7 +++--++
1 -++-++
2 --++++
3 --++++
4 --++++
5 +--+++
6 ++--++
m - (m/2+1)
m/2 + 1
n/2+1
n
n >= m
m > n
swap(n, m)
heruistics
10 20
--+-+-++++
--+-+-++++
-+--+-++++
-+--+-++++
-+-+--++++
-+-+--++++
+--+-+-+++
+--+-+-+++
+-+--+-+++
+-+--+-+++
10 10
--+-+-++++
--+-+-++++
-+--+-++++
-+--+-++++
-+-+--++++
-+-+--++++
+--+-+-+++
+--+-+-+++
+-+--+-+++
+-+--+-+++
8 1 7 3 4 5 6 10
0 1 1 2 2 2 2 0
++++---
++++---
++++---
-------
---++++
---++++
---++++
-
-
-
-
+
+
+
*/
ll a[N];
void solve()
{
int n, m;
cin >> n >> m;
for(int i = 1; i <= n; i ++)
cin >> a[i];
for(int i = 1; i <= m; i ++)
{
ll l, r, k;
cin >> l >> r >> k;
ll leftMax = 0, ans = 0;
for(int j = l; j <= r; j ++)
{
if(leftMax > a[j])
ans = max(ans, leftMax + a[j]);
leftMax = max(leftMax, a[j]);
}
cout << (ans <= k) << '\n';
}
}
int main()
{
int t = 1;
while(t --)
solve();
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |