이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define st first
#define nd second
#define pii pair<int,int>
#define N 1000005
#define INF 1e9+5
#define sp " "
#define endl "\n"
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);
#define all(x) (x).begin(),(x).end()
#define ll long long
using namespace std;
int n,m,l,r,k;
int main(){
cin >> n >> m;
vector<int> w(n+1);
vector<int> s(n+1);
for(int i=1;i<=n;i++){
cin >> w[i];
}
for(int i=1;i<=m;i++){
cin >> l >> r >> k;
int mx=0;
for(int j=l;j<=r;j++){
s[j]=w[j];
}
for(int j=l;j<=r;j++){
int h=j;
while(h>=l&&s[h]<s[h-1]){
swap(s[h],s[h-1]);
mx=max(mx,s[h-1]+s[h]);
h--;
}
}
if(mx<=k)
cout << 1 << endl;
else
cout << 0 << 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... |