結果

問題 No.1982 [Cherry 4th Tune B] 絶険
ユーザー hourenhouren
提出日時 2022-06-17 22:36:12
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,672 bytes
コンパイル時間 1,693 ms
コンパイル使用メモリ 169,384 KB
実行使用メモリ 10,752 KB
最終ジャッジ日時 2024-04-17 14:51:59
合計ジャッジ時間 8,020 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
10,752 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 15 ms
7,808 KB
testcase_03 TLE -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define fix(x) fixed << setprecision(x)
#define asc(x) x, vector<x>, greater<x>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define all(x) (x).begin(),(x).end()
template<class T>bool chmin(T&a, const T&b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool chmax(T&a, const T&b){if(a<b){a=b;return 1;}return 0;}

struct op{
    ll l,r,c,h;
};
struct query{
    ll I,x;
};
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n,k,q;
    const ll d = 1;
    cin >> n >> k >> q;
    vector<op> a(k);
    rep(i,k){
        cin >> a[i].l >> a[i].r >> a[i].c >> a[i].h;
        a[i].l--;
    }
    vector<ll> ans(q,-1);
    vector<query> b(q);
    rep(i,q){
        cin >> b[i].I >> b[i].x;
        b[i].I--;
    }
    ll tail = 0;
    vector<ll> tot(n+1,0);
    rep(i,k){
        vector<ll> imos(n+1,0);
        if(i*d>=k) break;
        auto pre = tot;
        tail += d;
        for(ll j=i*d;j<min(k,tail);j++){
            imos[a[j].l] += a[j].h;
            imos[a[j].r] -= a[j].h;
        }
        rep(j,n){
            tot[j] += imos[j];
            imos[j+1] += imos[j];
        }
        rep(j,q){
            ll itr = b[j].I, nh = pre[itr];
            if(ans[j]>0 || tot[itr]<b[j].x) continue;
            for(ll p=i*d;p<min(k,tail);p++){
                if(a[p].l<=itr && itr<a[p].r){
                    nh += a[p].h;
                    if(nh>=b[j].x){
                        ans[j] = a[p].c;
                        break;
                    }
                }
            }
        }
    }
    rep(i,q) cout << ans[i] << '\n';
    return 0;
}
0