답안 #798878

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
798878 2023-07-31T06:12:51 Z Alkarat Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) C++14
0 / 100
1459 ms 66748 KB
#include <bits/stdc++.h>
#define ll long long
#define f first
#define s second
const int N=1e6+10;
using namespace std;
int n,m,a[N],res[N];
struct query
{
    int id,l,r,lim;
    bool operator<(const query &x)const
    {
        return l>x.l;
    }
};
int bit[N];
void update(int id,int val)
{
    while(id<=n)
    {
        bit[id]=max(bit[id],val);
        id+=id&-id;
    }
}
int get(int id)
{
    int kq=0;
    while(id>0)
    {
        kq=max(kq,bit[id]);
        id-=id&-id;
    }
    return kq;
}
vector<query>q;
stack<int>st;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin>>n>>m;
    q.resize(m);
    for(int i=1; i<=n; i++) cin>>a[i];
    for(int i=0; i<=m-1; i++)
    {
        cin>>q[i].l>>q[i].r>>q[i].lim;
        q[i].id=i;
    }
    sort(q.begin(),q.end());
    int now=n+1;
    for(auto [id,l,r,lim]:q)
    {
        while(now>l)
        {
            now--;
            while(st.size()&&a[st.top()]<=a[now])
            {
                int x=st.top();
                update(x,a[now]+a[x]);
                st.pop();
            }
            st.push(now);
        }
        res[id]=(get(r)<=lim);
    }
    for(int i=0; i<=m-1; i++) cout<<res[i]<<endl;
}

Compilation message

sortbooks.cpp: In function 'int main()':
sortbooks.cpp:52:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   52 |     for(auto [id,l,r,lim]:q)
      |              ^
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 328 KB Output is correct
2 Correct 1 ms 328 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 324 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 2 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Incorrect 2 ms 340 KB Output isn't correct
11 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 328 KB Output is correct
2 Correct 1 ms 328 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 324 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 2 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Incorrect 2 ms 340 KB Output isn't correct
11 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1387 ms 61452 KB Output is correct
2 Correct 1459 ms 62648 KB Output is correct
3 Correct 1455 ms 62460 KB Output is correct
4 Correct 1417 ms 62748 KB Output is correct
5 Incorrect 1356 ms 66748 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 132 ms 5372 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 328 KB Output is correct
2 Correct 1 ms 328 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 324 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 2 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Incorrect 2 ms 340 KB Output isn't correct
11 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 328 KB Output is correct
2 Correct 1 ms 328 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 324 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 2 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Incorrect 2 ms 340 KB Output isn't correct
11 Halted 0 ms 0 KB -