이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include <math.h>
typedef long long ll;
using namespace std;
ll i, j, t, a, n, m, b, c, d, f, g;
int x[1000100], y[1000100];
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cin>>n>>m;
for (a=1; a<=n; a++) cin>>x[a];
for (a=1; a<=m; a++)
{
int l, r, k;
cin>>l>>r>>k;
int gmax=INT_MIN, mmax=INT_MIN;
int ans=1;
for (b=r; b>=l; b--)
{
// cout<<x[b]<<" "<<mmax<<" "<<gmax<<endl;
if (mmax<x[b])
{
if (mmax+x[b]>k)
{
ans=0;
break;
}
if (x[b]>gmax)
{
if (x[b]+gmax>k)
{
ans=0;
break;
}
gmax=x[b];
mmax=INT_MIN;
continue;
}
mmax=x[b];
// cout<<mmax<<endl;
continue;
}
}
cout<<ans<<endl;
}
}
/*
*/
# | 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... |