Submission #43652469


Source Code Expand

#include <bits/stdc++.h>

#define fastio ios_base::sync_with_stdio(0); cin.tie(0);
#define int long long

using namespace std;

signed main() {
    fastio
    int n, c;
    cin >> n >> c;

    map<int, int> mp;
    for (int i = 0; i < n; i++) {
        int l, r, v;
        cin >> l >> r >> v;
        mp[l] += v;
        mp[r+1] -= v;
    }

    int sum = 0, now = 0, prev = 0;

    for(auto [a,b] : mp){
        sum += min(c,now) * (a - prev);
        now += b;
        prev = a;
    }

    cout << sum << "\n";
}

Submission Info

Submission Time
Task D - Snuke Prime
User SamDaBest
Language C++ (GCC 9.2.1)
Score 400
Code Size 544 Byte
Status AC
Exec Time 302 ms
Memory 28592 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 3
AC × 28
Set Name Test Cases
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
Case Name Status Exec Time Memory
random_01.txt AC 10 ms 3376 KiB
random_02.txt AC 2 ms 3588 KiB
random_03.txt AC 2 ms 3548 KiB
random_04.txt AC 2 ms 3520 KiB
random_05.txt AC 2 ms 3404 KiB
random_06.txt AC 2 ms 3388 KiB
random_07.txt AC 2 ms 3588 KiB
random_08.txt AC 2 ms 3484 KiB
random_09.txt AC 2 ms 3468 KiB
random_10.txt AC 2 ms 3588 KiB
random_11.txt AC 2 ms 3588 KiB
random_12.txt AC 2 ms 3500 KiB
random_13.txt AC 2 ms 3548 KiB
random_14.txt AC 2 ms 3592 KiB
random_15.txt AC 2 ms 3484 KiB
random_16.txt AC 65 ms 10336 KiB
random_17.txt AC 122 ms 17412 KiB
random_18.txt AC 106 ms 15628 KiB
random_19.txt AC 96 ms 14552 KiB
random_20.txt AC 242 ms 28260 KiB
random_21.txt AC 179 ms 21400 KiB
random_22.txt AC 27 ms 5812 KiB
random_23.txt AC 302 ms 28592 KiB
random_24.txt AC 294 ms 28392 KiB
random_25.txt AC 51 ms 3544 KiB
sample_01.txt AC 3 ms 3588 KiB
sample_02.txt AC 2 ms 3548 KiB
sample_03.txt AC 2 ms 3544 KiB