# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
284785 | dantoh000 | Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) | C++14 | 514 ms | 17052 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>
using namespace std;
typedef pair<int,int> ii;
int n,m;
int w[5005];
vector<ii> v[5005];
int main(){
scanf("%d%d",&n,&m);
if (n > 5000) return 0;
for (int i = 1; i <= n; i++) scanf("%d",&w[i]);
for (int i = 1; i <= n; i++){
for (int j = i+1; j <= n; j++){
if (w[j] < w[i] && (v[i].size() == 0 || w[j] > v[i].back().second)) v[i].push_back({j,w[j]});
}
}
for (int i = 0; i < m; i++){
int l,r,k;
scanf("%d%d%d",&l,&r,&k);
int ans = 1;
for (int j = l; j <= r; j++){
int p = upper_bound(v[j].begin(),v[j].end(),ii(r+1,-1))-v[j].begin();
//printf("%d %d -> %d\n",j,w[j],p);
if (p == 0){
continue;
}
else{
p--;
if (w[j]+v[j][p].second > k) ans = 0;
}
}
printf("%d\n",ans);
}
}
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... |