답안 #147806

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
147806 2019-08-30T17:23:36 Z leatherman Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) C++14
0 / 100
3000 ms 20624 KB
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

#pragma GCC optimize("-O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

#define ll int
#define ld long double
#define endl "\n"
#define fi first
#define se second
#define y1 sadjfskldf
#define PB push_back
#define sqr(x) ((x) * (x))
#define all(x) x.begin(), x.end()
using namespace std;
using namespace __gnu_pbds;
mt19937_64 rnd(chrono::system_clock::now().time_since_epoch().count());

const ll N = 1e6 + 100;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
struct tre
{
    ll val = 0,ans = 0;
};
tre t[4 * N];
ll a[N],n,m,l,r,k,x;
void build(ll v,ll tl,ll tr)
{
    if(tl == tr)
    {
        t[v].val = a[tl];
        return;
    }
    ll tm = (tl + tr) / 2;
    build(2 * v, tl, tm);
    build(2 * v + 1, tm + 1, tr);

    t[v].ans = max(max(t[2 * v].ans, t[2 * v + 1].ans), (t[2 * v].val + t[2 * v + 1].val) * (t[2 * v].val > t[2 * v + 1].val));
    t[v].val = max(t[2 * v].val, t[2 * v + 1].val);
}
tre get(ll v,ll tl,ll tr,ll l,ll r)
{
    if(l > r)
    {
        tre pisos;
        pisos.val = pisos.ans = -1e9;
        return pisos;
    };
    if(tl == tr) return t[v];
    ll tm = (tl + tr) / 2;
    tre res,x,y;
    x = get(2 * v, tl, tm, l, min(r, tm));
    y = get(2 * v + 1, tm + 1, tr, max(l, tm + 1), r);
    res.ans = max(max(x.ans, y.ans), (x.val + y.val) * (x.val > y.val));
    res.val = max(x.val, y.val);
    return res;
}
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin>>n>>m;
    for(int i = 1; i <= n; i++) cin>>a[i];
    build(1, 1, n);
    for(int i = 1; i <= m; i++)
    {
        cin>>l>>r>>k;
        x = get(1, 1, n, l, r).ans;
        if(x > k) cout<<0;
        else cout<<1<<endl;
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Incorrect 2 ms 376 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Incorrect 2 ms 376 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3010 ms 20624 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3033 ms 3064 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Incorrect 2 ms 376 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Incorrect 2 ms 376 KB Output isn't correct
4 Halted 0 ms 0 KB -