# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
690426 | White | Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) | C++14 | 188 ms | 262144 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
vector<pair<long long,long long>>ans[1000005];
long long red[1000005];
stack<pair<long long,long long>>s;
long long binary(long long v,long long num){
long long l=0,r=ans[v].size()-1;
while(l<r){
long long mid=(r+l)/2;
if(ans[v][mid].second<num)l=mid+1;
else r=mid;
}
return l;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
long long n,m;
cin>>n>>m;
for(long long i=0;i<n;i++)cin>>red[i];
s.push({red[0],0});
for(long long i=1;i<n;i++){
ans[i]=ans[i-1];
while(s.empty()!=true && red[i]>=s.top().first)s.pop();
if(s.empty()!=true){
ans[i].push_back({s.top().first+red[i],s.top().second});
for(long long j=0;j<ans[i].size()-1;j++){
if(ans[i][j].first<red[ans[i][j].second]+red[i]){
ans[i][j].first=red[ans[i][j].second]+red[i];
}
}
}
s.push({red[i],i});
}
/**
for(long long i=0;i<n;i++){
cout<<i<<": ";
for(long long j=0;j<ans[i].size();j++){
cout<<ans[i][j].first<<";"<<ans[i][j].second<<" ";
}
cout<<endl;
}
**/
for(long long i=0;i<m;i++){
long long a,b,c,now;
cin>>a>>b>>c;
a--;b--;
now=binary(b,a);
if(ans[b][now].second<a)cout<<1<<endl;
else {
//cout<<ans[b][now].first<<endl;
if(ans[b].size()==0 || c>=ans[b][now].first)cout<<1<<endl;
else cout<<0<<endl;
}
}
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... |