이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define fcc ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define sqr(a) (a) * (a)
#define all(x) x.begin(), x.end()
#define rall(x) x.rebgin(), x.rend()
#define pb push_back
#define mp make_pair
#define int long long
#define ff first
#define ss second
#define endl "\n"
using namespace std;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef set<int> si;
int a[500009], b[500009];
void solve() {
int n, m, l, r, k;
cin >> n >> m;
int a[n + 1];
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
a[0] = 0;
while (m--) {
cin >> l >> r >> k;
int ans = 0, leftmax = 0;
for (int i = l; i <= r; i++) {
if (leftmax > a[i]) {
ans = max(ans, leftmax + a[i]);
}
leftmax = max(leftmax, a[i]);
}
if (ans <= k) {
cout << "1\n";
}
else {
cout << "0\n";
}
}
}
signed main() {
fcc;
int t = 1;
// cin >> t;
while (t--) {
solve();
cout << '\n';
}
}
# | 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... |