# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
689961 | 2023-01-29T22:06:43 Z | White | Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) | C++14 | 2 ms | 608 KB |
#include <bits/stdc++.h> #define endl "\n" using namespace std; vector<pair<int,int>>ans[1005]; int red[1005]; stack<pair<int,int>>s; int binary(int v,int num){ int l=0,r=ans[v].size()-1; while(l<r){ int 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); int n,m; cin>>n>>m; for(int i=0;i<n;i++)cin>>red[i]; s.push({red[0],0}); for(int 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(int 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(int i=0;i<n;i++){ cout<<i<<": "; for(int j=0;j<ans[i].size();j++){ cout<<ans[i][j].first<<";"<<ans[i][j].second<<" "; } cout<<endl; } **/ for(int i=0;i<m;i++){ int a,b,c,now; cin>>a>>b>>c; a--;b--; now=binary(b,a); if(now>ans[b].size()-1)now=ans[b].size()-1; if(c>=ans[b][now].first)cout<<1<<endl; else cout<<0<<endl; } return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 340 KB | Output is correct |
2 | Runtime error | 1 ms | 468 KB | Execution killed with signal 11 |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 340 KB | Output is correct |
2 | Runtime error | 1 ms | 468 KB | Execution killed with signal 11 |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 2 ms | 468 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 1 ms | 608 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 340 KB | Output is correct |
2 | Runtime error | 1 ms | 468 KB | Execution killed with signal 11 |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 340 KB | Output is correct |
2 | Runtime error | 1 ms | 468 KB | Execution killed with signal 11 |
3 | Halted | 0 ms | 0 KB | - |