# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1094878 | Kerim | Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) | C++17 | 604 ms | 93804 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "bits/stdc++.h"
#define MAXN 1000009
#define INF 1000000007
#define mp(x,y) make_pair(x,y)
#define all(v) v.begin(),v.end()
#define pb(x) push_back(x)
#define wr cout<<"----------------"<<endl;
#define ppb() pop_back()
#define tr(ii,c) for(__typeof((c).begin()) ii=(c).begin();ii!=(c).end();ii++)
#define ff first
#define ss second
#define my_little_dodge 46
#define debug(x) cerr<< #x <<" = "<< x<<endl;
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
int F[MAXN],arr[MAXN],k[MAXN],ans[MAXN];
vector<PII>adj[MAXN];
void upd(int x,int val){
for(;x;x-=x&(-x))
umax(F[x],val);
}
int tap(int x){
int res=0;
for(;x<MAXN;x+=x&(-x))
umax(res,F[x]);
return res;
}
int main(){
// freopen("file.in", "r", stdin);
int n,q;
scanf("%d%d",&n,&q);
for(int i=1;i<=n;i++)
scanf("%d",arr+i);
for(int i=1;i<=q;i++){
int l,r;
scanf("%d%d%d",&l,&r,&k[i]);
adj[r].pb(mp(l,i));
}
stack<int>st;
for(int i=1;i<=n;i++){
while(!st.empty() and arr[st.top()]<=arr[i])
st.pop();
if(!st.empty())
upd(st.top(),arr[st.top()]+arr[i]);
tr(it,adj[i])
if(tap(it->ff)<=k[it->ss])
ans[it->ss]=1;
st.push(i);
}
for(int i=1;i<=q;i++)
printf("%d\n",ans[i]);
return 0;
}
컴파일 시 표준 에러 (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... |