結果

問題 No.448 ゆきこーだーの雨と雪 (3)
ユーザー monman53monman53
提出日時 2018-02-07 10:52:15
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,526 bytes
コンパイル時間 1,870 ms
コンパイル使用メモリ 151,288 KB
実行使用メモリ 7,684 KB
最終ジャッジ日時 2023-10-12 10:52:27
合計ジャッジ時間 7,253 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,352 KB
testcase_01 AC 2 ms
4,352 KB
testcase_02 AC 1 ms
4,352 KB
testcase_03 AC 1 ms
4,348 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 61 ms
6,812 KB
testcase_18 AC 10 ms
4,352 KB
testcase_19 WA -
testcase_20 AC 28 ms
4,472 KB
testcase_21 AC 78 ms
7,228 KB
testcase_22 AC 28 ms
4,732 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 78 ms
7,212 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 12 ms
4,352 KB
testcase_32 AC 13 ms
4,348 KB
testcase_33 WA -
testcase_34 AC 86 ms
7,432 KB
testcase_35 WA -
testcase_36 AC 85 ms
7,368 KB
testcase_37 WA -
testcase_38 AC 86 ms
7,684 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// header {{{
#include <bits/stdc++.h>
using namespace std;

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define LLINF       LLONG_MAX/3
#define MOD         (1000000007LL)
#define MODA(a, b)  a=((a)+(b))%MOD
#define MODP(a, b)  a=((a)*(b))%MOD
#define inc(i, l, r)   for(long long i=(l);i<(r);i++)
#define dec(i, l, r)   for(long long i=(r)-1;i>=(l);i--)
#define pb          push_back
#define se          second
#define fi          first
#define mset(a, b)  memset(a, b, sizeof(a))

using LL  = long long;
using G   = vector<vector<int>>;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

int main() {
    std::ios::sync_with_stdio(false);
    int n, k;cin >> n >> k;
    vector<int> t(n), d(n), flag(n, 1);
    priority_queue<pair<int, int>> pq;
    inc(i, 0, n){
        cin >> t[i] >> d[i];
        pq.push({d[i], i});
    }
    int ansmax = 0;
    LL  anssum = 0;
    while(!pq.empty()){
        int i = pq.top().second;
        pq.pop();
        if(!flag[i]) continue;
        flag[i] = false;
        for(int j=i+1;j<n;j++){
            if(!flag[j]) break;
            if(t[j]-t[i] >= k) break;
            flag[j] = false;
            ansmax = max(ansmax, d[j]);
            anssum += d[j];
        }
        for(int j=i-1;j>=0;j--){
            if(!flag[j]) break;
            if(t[i]-t[j] >= k) break;
            flag[j] = false;
            ansmax = max(ansmax, d[j]);
            anssum += d[j];
        }
    }
    cout << ansmax << endl;
    cout << anssum << endl;
    return 0;
}
0