답안 #539319

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
539319 2022-03-18T17:31:13 Z Evang Hedgehog Daniyar and Algorithms (IZhO19_sortbooks) C++17
13 / 100
1056 ms 96296 KB
#include <bits/extc++.h>
using namespace std;
using namespace __gnu_pbds;

#ifdef _DEBUG
#define dout(x) clog << "Line " << __LINE__ << ": " << #x << "=" << (x) << el
#else
#define dout(x)
#endif

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define uid(a,b) uniform_int_distribution<int>(a,b)(rng)

#define ins insert
#define ssize(x) (int((x).size()))
#define bs(args...) binary_search(args)
#define lb(args...) lower_bound(args)
#define ub(args...) upper_bound(args)
#define all(x) (x).begin(),(x).end()
#define mp(a, b) make_pair(a, b)
#define mt(args...) make_tuple(args)
#define pb push_back
#define eb emplace_back
#define ff first
#define ss second
#define die exit(0)

template<typename T>
using vc = vector<T>;
template<typename T>
using uset = unordered_set<T>;
template<typename A, typename B>
using umap = unordered_map<A, B>;
template<typename T, typename Comp>
using pq = std::priority_queue<T, vc<T>, Comp>;
template<typename T>
using maxpq = pq<T, less<T>>;
template<typename T>
using minpq = pq<T, greater<T>>;
template<typename T>
using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

using db = double;
using ld = long double;
using ll = long long;
using ull = unsigned long long;
using pi = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vc<int>;
using vll = vc<ll>;
using vpi = vc<pi>;
using vpll = vc<pll>;
using str = string;

constexpr char el = '\n';
constexpr char sp = ' ';
constexpr int inf = 0x3f3f3f3f;
constexpr ll llinf = 0x3f3f3f3f3f3f3f3fLL;
// ---------------------------------------------------------------------


const int N = 1e6+5;
const int Q = N;
int n, q, a[N], bit[N];
vi qs[N];
bitset<N> ans;
struct evan {
    int l, r, k;
} query[Q];

void upd(int i, int x){
    while(i>0){
        bit[i] = max(bit[i], x);
        i -= i&-i;
    }
}

int qry(int i){
    int ans = 0;
    while(i<=n){
        ans = max(ans, bit[i]);
        i += i&-i;
    }
    return ans;
}

signed main() {
    ios::sync_with_stdio(0); cin.tie(0);
    cout << fixed; clog << fixed; clog << unitbuf;
#ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("debug.txt", "w", stderr);
#else
    //freopen(".in", "r", stdin);
    //freopen(".out", "w", stdout);
#endif

    cin >> n >> q;
    a[0] = inf;
    for(int i = 1; i <= n; ++i)
        cin >> a[i];
    for(int i = 0; i < n; ++i){
        cin >> query[i].l >> query[i].r >> query[i].k;
        qs[query[i].r].pb(i);
    }

    vi st{0};
    for(int i = 1; i <= n; ++i){
        while(a[st.back()]<=a[i])
            st.pop_back();
        upd(st.back(), a[i]+a[st.back()]);
        st.pb(i);
        for(int j: qs[i])
            ans[j] = qry(query[j].l) <= query[j].k;
    }
    for(int i = 0; i < q; ++i)
        cout << ans[i] << el;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 23764 KB Output is correct
2 Correct 14 ms 23764 KB Output is correct
3 Incorrect 13 ms 23764 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 23764 KB Output is correct
2 Correct 14 ms 23764 KB Output is correct
3 Incorrect 13 ms 23764 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 982 ms 95256 KB Output is correct
2 Correct 1014 ms 96296 KB Output is correct
3 Correct 983 ms 96236 KB Output is correct
4 Correct 1026 ms 96228 KB Output is correct
5 Correct 1056 ms 92408 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 82 ms 27608 KB Output is correct
2 Correct 66 ms 28768 KB Output is correct
3 Correct 79 ms 28896 KB Output is correct
4 Correct 90 ms 29024 KB Output is correct
5 Correct 72 ms 29140 KB Output is correct
6 Correct 60 ms 27928 KB Output is correct
7 Correct 65 ms 27908 KB Output is correct
8 Correct 74 ms 28824 KB Output is correct
9 Incorrect 20 ms 24156 KB Output isn't correct
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 23764 KB Output is correct
2 Correct 14 ms 23764 KB Output is correct
3 Incorrect 13 ms 23764 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 23764 KB Output is correct
2 Correct 14 ms 23764 KB Output is correct
3 Incorrect 13 ms 23764 KB Output isn't correct
4 Halted 0 ms 0 KB -