結果

問題 No.1982 [Cherry 4th Tune B] 絶険
ユーザー 👑 NachiaNachia
提出日時 2024-04-18 02:37:16
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 318 ms / 3,000 ms
コード長 1,544 bytes
コンパイル時間 1,387 ms
コンパイル使用メモリ 100,228 KB
実行使用メモリ 36,044 KB
最終ジャッジ日時 2024-04-18 02:37:31
合計ジャッジ時間 12,430 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,816 KB
testcase_01 AC 2 ms
6,816 KB
testcase_02 AC 8 ms
12,648 KB
testcase_03 AC 111 ms
16,440 KB
testcase_04 AC 140 ms
15,360 KB
testcase_05 AC 122 ms
16,896 KB
testcase_06 AC 178 ms
22,768 KB
testcase_07 AC 219 ms
26,188 KB
testcase_08 AC 177 ms
16,768 KB
testcase_09 AC 179 ms
23,388 KB
testcase_10 AC 176 ms
21,084 KB
testcase_11 AC 98 ms
13,824 KB
testcase_12 AC 176 ms
19,328 KB
testcase_13 AC 95 ms
11,392 KB
testcase_14 AC 116 ms
19,444 KB
testcase_15 AC 116 ms
12,160 KB
testcase_16 AC 144 ms
23,080 KB
testcase_17 AC 259 ms
30,488 KB
testcase_18 AC 228 ms
28,520 KB
testcase_19 AC 272 ms
31,052 KB
testcase_20 AC 46 ms
12,528 KB
testcase_21 AC 67 ms
17,848 KB
testcase_22 AC 141 ms
13,440 KB
testcase_23 AC 62 ms
12,552 KB
testcase_24 AC 90 ms
12,928 KB
testcase_25 AC 249 ms
25,540 KB
testcase_26 AC 273 ms
27,940 KB
testcase_27 AC 46 ms
8,448 KB
testcase_28 AC 100 ms
18,628 KB
testcase_29 AC 271 ms
31,376 KB
testcase_30 AC 185 ms
29,420 KB
testcase_31 AC 109 ms
18,844 KB
testcase_32 AC 318 ms
35,180 KB
testcase_33 AC 301 ms
36,044 KB
testcase_34 AC 291 ms
36,012 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <atcoder/segtree>
using namespace std;
using i64 = long long;
#define rep(i,n) for(int i=0; i<(int)(n); i++)


const i64 INF = 1001001001001001001;

template<class S> struct SegtreeSum{
    static S op(S l, S r){ return l + r; }
    static S e(){ return S(0); }
    using Type = struct atcoder::segtree<S,op,e>;
    struct LessThan{
        S y;
        LessThan(const S& s) : y(s) {}
        bool operator()(S x) const { return x < y; }
    };
};


int main(){
	std::ios::sync_with_stdio(false);
	std::cin.tie(nullptr);
    int N; cin >> N;
    int K; cin >> K;
    int Q; cin >> Q;

    struct AddQuery{ int p; i64 x; };
    vector<vector<AddQuery>> addQueries(N+1);
    vector<int> col(K+1, -1);

    rep(i,K){
        int l; cin >> l; l--;
        int r; cin >> r;
        int c; cin >> c;
        int k; cin >> k;
        addQueries[l].push_back({ i, k });
        addQueries[r].push_back({ i, -k });
        col[i] = c;
    }

    struct AnswerQuery{ i64 h; int idx; };
    vector<vector<AnswerQuery>> answerQueries(N);
    rep(i,Q){
        int p; cin >> p; p--;
        i64 h; cin >> h;
        answerQueries[p].push_back({ h, i });
    }

    vector<int> ans(Q, -1);
    SegtreeSum<i64>::Type rq(K);

    rep(i,N){
        for(auto q : addQueries[i]) rq.set(q.p, rq.get(q.p) + q.x);
        for(auto q : answerQueries[i]) ans[q.idx] = col[rq.max_right(0, SegtreeSum<i64>::LessThan(q.h))];
    }

    rep(i,Q) cout << ans[i] << '\n';
    return 0;
}
0