提出 #19383871


ソースコード 拡げる

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

using ll = long long;
using vi = vector<int>;
using vll = vector<long long>;
using pll = pair<long long, long long>;

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

constexpr long long mod = 1000000007;

#define rep(i, n) for (int i = 0; i < n; i++)

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    ll n, c;
    cin >> n >> c;

    vector<pll> v;
    rep(i, n) {
        ll a, b, d;
        cin >> a >> b >> d;

        v.push_back(make_pair(a - 1, d));
        v.push_back(make_pair(b, -d));
    }

    sort(v.begin(), v.end());

    ll sum = 0;
    ll fee = 0;
    ll t = 0;
    for (auto p : v) {
        if(p.first!=t){
            sum += min(fee, c) * (p.first - t);
            t = p.first;
        }
        fee += p.second;
    }

    cout << sum << endl;
}

提出情報

提出日時
問題 D - Snuke Prime
ユーザ himajin008
言語 C++ (GCC 9.2.1)
得点 400
コード長 884 Byte
結果 AC
実行時間 94 ms
メモリ 11492 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 400 / 400
結果
AC × 3
AC × 28
セット名 テストケース
Sample sample_01.txt, sample_02.txt, sample_03.txt
All random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, random_23.txt, random_24.txt, random_25.txt, sample_01.txt, sample_02.txt, sample_03.txt
ケース名 結果 実行時間 メモリ
random_01.txt AC 8 ms 3532 KiB
random_02.txt AC 2 ms 3552 KiB
random_03.txt AC 2 ms 3484 KiB
random_04.txt AC 2 ms 3484 KiB
random_05.txt AC 3 ms 3544 KiB
random_06.txt AC 2 ms 3548 KiB
random_07.txt AC 2 ms 3532 KiB
random_08.txt AC 2 ms 3552 KiB
random_09.txt AC 3 ms 3536 KiB
random_10.txt AC 3 ms 3532 KiB
random_11.txt AC 3 ms 3524 KiB
random_12.txt AC 3 ms 3472 KiB
random_13.txt AC 3 ms 3484 KiB
random_14.txt AC 3 ms 3472 KiB
random_15.txt AC 3 ms 3516 KiB
random_16.txt AC 34 ms 5160 KiB
random_17.txt AC 54 ms 7244 KiB
random_18.txt AC 50 ms 7296 KiB
random_19.txt AC 51 ms 7240 KiB
random_20.txt AC 93 ms 11472 KiB
random_21.txt AC 70 ms 11436 KiB
random_22.txt AC 18 ms 4136 KiB
random_23.txt AC 92 ms 11404 KiB
random_24.txt AC 94 ms 11492 KiB
random_25.txt AC 71 ms 11488 KiB
sample_01.txt AC 6 ms 3480 KiB
sample_02.txt AC 2 ms 3524 KiB
sample_03.txt AC 2 ms 3552 KiB