# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
572073 | Hanksburger | Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) | C++17 | 865 ms | 76616 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
vector<pair<pair<int, int>, int> > v[1000005];
int a[1000005], b[1000005];
vector<pair<int, int> > w;
bool c[1000005];
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n, q;
cin >> n >> q;
for (int i=1; i<=n; i++)
cin >> a[i];
for (int i=1; i<=q; i++)
{
int l, r, x;
cin >> l >> r >> x;
v[r].push_back({{l, x}, i});
}
for (int i=1; i<=n; i++)
{
while (w.size() && w[w.size()-1].first<=a[i])
w.pop_back();
if (w.size())
{
int x=w[w.size()-1].first+a[i];
for (int i=w[w.size()-1].second; i; i-=(i&-i))
b[i]=max(b[i], x);
}
w.push_back({a[i], i});
for (int j=0; j<v[i].size(); j++)
{
int mx=0;
for (int k=v[i][j].first.first; k<=n; k+=(k&-k))
mx=max(mx, b[k]);
c[v[i][j].second]=(mx<=v[i][j].first.second);
}
}
for (int i=1; i<=q; i++)
cout << c[i] << '\n';
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... |