# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
218339 | Lawliet | Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) | C++14 | 1078 ms | 52604 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1000010;
const int INF = 1000000010;
struct query
{
int L, k;
int ind;
query(int l, int k, int i)
: L(l), k(k), ind(i) {}
};
int n, q;
int v[MAXN];
bool ans[MAXN];
vector< int > s;
vector< query > sweep[MAXN];
int main()
{
scanf("%d %d",&n,&q);
v[0] = INF;
s.push_back( 0 );
for(int i = 1 ; i <= n ; i++)
scanf("%d",&v[i]);
for(int i = 1 ; i <= q ; i++)
{
int L, R, k;
scanf("%d %d %d",&L,&R,&k);
sweep[R].push_back( query( L , k , i ) );
}
for(int i = 1 ; i <= n ; i++)
{
while( v[ s.back() ] <= v[i] )
s.pop_back();
s.push_back( i );
while( !sweep[i].empty() )
{
int curL = sweep[i].back().L;
int curK = sweep[i].back().k;
int curInd = sweep[i].back().ind;
sweep[i].pop_back();
int aux = lower_bound( s.begin() , s.end() , curL ) - s.begin();
if( aux == s.size() - 1 ) ans[curInd] = true;
else
{
int A = v[ s[aux] ];
int B = v[ s[aux + 1] ];
ans[curInd] = ( A + B <= curK );
}
}
}
for(int i = 1 ; i <= q ; i++)
{
if( ans[i] ) printf("1\n");
else printf("0\n");
}
}
컴파일 시 표준 에러 (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... |