이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
signed main(){
int n, m; cin >> n >> m;
vi w; w.assign(n, 0);
for (int i=0; i<n; i++) cin >> w[i];
for (int i=0; i<m; i++){
int l, r, k;
cin >> l >> r >> k; l--; r--;
//Solve
vii v; v.assign(r-l+1, ii());
int res=0;
for (int i=l; i<=r; i++) v[i-l]=ii(w[i], i);
sort(v.begin(), v.end());
for (int p=0; p<r-l+1; p++){
int a = v[p].first;
int b = v[p].second;
if (b==0) continue;
int c = w[max_element(w.begin()+l, w.begin()+l+b)-w.begin()];
if (a<c) res = max(res, a+c);
if (res>k) break;
}
if (res<=k) cout << 1 << endl;
else cout << 0 << endl;
//cout << res << endl;
//EndSolve
}
}
# | 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... |