# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
498166 | OrazB | Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) | C++14 | 3061 ms | 1360 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define N 100005
#define ll long long int
#define pii pair <int, int>
#define pb push_back
#define ff first
#define ss second
using namespace std;
int n, m, l, r, k, mx, tr, a[N];
vector <pii> v;
int main ()
{
ios::sync_with_stdio(false);
cin.tie(0);
cin >> n >> m;
for (int i = 1; i <= n; i++) cin >> a[i];
for (int h = 1; h <= m; h++){
cin >> l >> r >> k;
tr = 0; v.clear();
for (int i = l; i <= r; i++) v.pb({a[i], i});
sort(v.begin(), v.end());
for (int i = 0; i < v.size(); i++){
if (v[i].ss != i + 1){
for (int j = i + 1; j <= v[i].ss; j++) mx = max(mx, a[j]);
if (v[i].ff + mx > k){tr = 1; break;}
mx = 0;
}
}
if (tr) cout << "0\n";
else cout << "1\n";
}
}
Compilation message (stderr)
# | 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... |