답안 #746530

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
746530 2023-05-22T16:34:30 Z Denkata Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) C++14
0 / 100
915 ms 74996 KB
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
const int maxn = 1e6+3;
long long i,j,p,q,n,m,k,a[maxn],Q,b[maxn];
char s[maxn];
struct Pic
{
    long long l,k,ind;
};
vector <Pic> queries[maxn];
void upd(long long p,long long val)
{
    while(p>=0)
    {
        b[p]=max(b[p],val);
        p=(p&(p+1))-1;
    }
}
long long rsq(long long p)
{
    long long sum = 0;
    while(p<=n)
    {
        sum = max(sum,b[p]);
        p = (p|(p+1));
    }
    return sum;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>n>>Q;
    for(i=1;i<=n;i++)
        cin>>a[i];
    for(i=1;i<=Q;i++)
    {
        cin>>p>>q>>k;
        queries[q].push_back({p,k,i});
    }
    stack <int> st;
    for(i=1;i<=n;i++)
    {
        while(!st.empty() && a[st.top()]<a[i])
        {
            st.pop();
        }
        if(!st.empty())
            upd(st.top(),a[st.top()]+a[i]);
        st.push(i);
        for(auto j:queries[i])
            s[j.ind] = (char)((rsq(j.l)<=j.k)+ '0');
    }
    for(i=1;i<=Q;i++)
        cout<<s[i]<<endl;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 23788 KB Output is correct
2 Correct 13 ms 23820 KB Output is correct
3 Correct 13 ms 23820 KB Output is correct
4 Correct 13 ms 23816 KB Output is correct
5 Correct 13 ms 23764 KB Output is correct
6 Correct 13 ms 23816 KB Output is correct
7 Correct 13 ms 23752 KB Output is correct
8 Correct 15 ms 23824 KB Output is correct
9 Correct 14 ms 23764 KB Output is correct
10 Incorrect 13 ms 23748 KB Output isn't correct
11 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 23788 KB Output is correct
2 Correct 13 ms 23820 KB Output is correct
3 Correct 13 ms 23820 KB Output is correct
4 Correct 13 ms 23816 KB Output is correct
5 Correct 13 ms 23764 KB Output is correct
6 Correct 13 ms 23816 KB Output is correct
7 Correct 13 ms 23752 KB Output is correct
8 Correct 15 ms 23824 KB Output is correct
9 Correct 14 ms 23764 KB Output is correct
10 Incorrect 13 ms 23748 KB Output isn't correct
11 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 822 ms 74996 KB Output is correct
2 Correct 915 ms 74956 KB Output is correct
3 Correct 811 ms 74816 KB Output is correct
4 Correct 860 ms 74844 KB Output is correct
5 Incorrect 782 ms 74924 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 63 ms 29104 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 23788 KB Output is correct
2 Correct 13 ms 23820 KB Output is correct
3 Correct 13 ms 23820 KB Output is correct
4 Correct 13 ms 23816 KB Output is correct
5 Correct 13 ms 23764 KB Output is correct
6 Correct 13 ms 23816 KB Output is correct
7 Correct 13 ms 23752 KB Output is correct
8 Correct 15 ms 23824 KB Output is correct
9 Correct 14 ms 23764 KB Output is correct
10 Incorrect 13 ms 23748 KB Output isn't correct
11 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 23788 KB Output is correct
2 Correct 13 ms 23820 KB Output is correct
3 Correct 13 ms 23820 KB Output is correct
4 Correct 13 ms 23816 KB Output is correct
5 Correct 13 ms 23764 KB Output is correct
6 Correct 13 ms 23816 KB Output is correct
7 Correct 13 ms 23752 KB Output is correct
8 Correct 15 ms 23824 KB Output is correct
9 Correct 14 ms 23764 KB Output is correct
10 Incorrect 13 ms 23748 KB Output isn't correct
11 Halted 0 ms 0 KB -