結果

問題 No.448 ゆきこーだーの雨と雪 (3)
ユーザー t98slidert98slider
提出日時 2023-03-26 18:58:42
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,163 bytes
コンパイル時間 4,908 ms
コンパイル使用メモリ 233,948 KB
実行使用メモリ 17,344 KB
最終ジャッジ日時 2023-10-19 13:49:11
合計ジャッジ時間 11,709 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 3 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 WA -
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 WA -
testcase_13 AC 29 ms
5,140 KB
testcase_14 AC 33 ms
5,140 KB
testcase_15 AC 88 ms
9,824 KB
testcase_16 WA -
testcase_17 AC 160 ms
15,760 KB
testcase_18 AC 24 ms
4,876 KB
testcase_19 WA -
testcase_20 AC 70 ms
7,252 KB
testcase_21 AC 206 ms
16,816 KB
testcase_22 AC 75 ms
9,560 KB
testcase_23 AC 210 ms
16,816 KB
testcase_24 WA -
testcase_25 AC 205 ms
16,816 KB
testcase_26 WA -
testcase_27 AC 156 ms
15,760 KB
testcase_28 WA -
testcase_29 AC 80 ms
9,560 KB
testcase_30 WA -
testcase_31 AC 29 ms
5,140 KB
testcase_32 AC 32 ms
5,140 KB
testcase_33 WA -
testcase_34 AC 225 ms
17,344 KB
testcase_35 WA -
testcase_36 AC 222 ms
17,344 KB
testcase_37 WA -
testcase_38 AC 225 ms
17,344 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using ll = long long;

using S = pair<int, ll>;
using F = int;
//単位元
S e(){return make_pair(1 << 30, 1 << 30);}
//演算
S op(S l,S r){return min(l, r);}
//xにfを作用させた時の値の変化
S mapping(F f,S x){return make_pair(max(x.first, f), x.second);}
//gを演算した後にfを演算させると演算子はどうなるか
F composition(F f, F g){return max(f, g);}
//作用させても変化させないもの
F id(){return 0;}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, K;
    cin >> N >> K;
    vector<int> T(N + 1), D(N + 1);
    for(int i = 1; i <= N; i++) cin >> T[i] >> D[i];
    T[0] = -(1 << 30);
    atcoder::lazy_segtree<S, op, e, F, mapping, composition, id> seg(N + 1);
    seg.set(0, {0, 0});
    ll s = accumulate(D.begin(), D.end(), 0ll);
    for(int i = 1, r = 0; i <= N; i++){
        while(T[r] + K <= T[i]) r++;
        auto p = seg.prod(0, r);
        p.second -= D[i];
        seg.set(i, p);
        seg.apply(0, i, D[i]);
    }
    auto p = seg.all_prod();
    cout << p.first << '\n';
    cout << s + p.second << '\n';
}
0