Submission #19435243


Source Code Expand

Copy
#include <iostream>
#include<string>
#include<vector>
#include<map>
#include<algorithm>
using namespace std;

#define PI acos(-1)
#define M 1000000007

void textIO()
{
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
}

void fastIO()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);

}


int main()
{
    textIO();
    fastIO();

    long long n, c, ans = 0, sum = 0;
    cin >> n >> c;
    map<long long, long long> mp;
    map<long long, long long>::iterator it;

    for(int i=0;i<n;i++){
        long long a, b, c;
        cin >> a >> b >> c;
        mp[(a)]+=c;
        mp[(b+1)]+=-c;
    }


//    for(auto x: mp){
//        cout << x.first << " " << x.second << '\n';
//    }

    long long pd = 0;

    for(auto x: mp){
        sum += x.second;
        ans += (x.first - pd)*min(c, sum);

        //cout << c << " " << sum << "-> " << ans << '\n';
        pd = x.first;
    }

    cout << ans << '\n';

    return 0;
}

Submission Info

Submission Time
Task D - Snuke Prime
User roslinmahmud
Language C++ (GCC 9.2.1)
Score 0
Code Size 1065 Byte
Status WA
Exec Time 335 ms
Memory 28524 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 400
Status
AC × 1
WA × 2
AC × 3
WA × 25
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 WA 9 ms 3548 KB
random_02.txt WA 2 ms 3496 KB
random_03.txt WA 3 ms 3568 KB
random_04.txt WA 2 ms 3596 KB
random_05.txt WA 2 ms 3556 KB
random_06.txt WA 2 ms 3568 KB
random_07.txt WA 3 ms 3512 KB
random_08.txt WA 3 ms 3492 KB
random_09.txt WA 9 ms 3560 KB
random_10.txt WA 2 ms 3496 KB
random_11.txt AC 2 ms 3440 KB
random_12.txt AC 2 ms 3440 KB
random_13.txt WA 2 ms 3448 KB
random_14.txt WA 2 ms 3452 KB
random_15.txt WA 2 ms 3404 KB
random_16.txt WA 64 ms 10456 KB
random_17.txt WA 142 ms 17412 KB
random_18.txt WA 115 ms 15484 KB
random_19.txt WA 107 ms 14636 KB
random_20.txt WA 294 ms 28200 KB
random_21.txt WA 216 ms 21520 KB
random_22.txt WA 23 ms 5712 KB
random_23.txt WA 335 ms 28524 KB
random_24.txt WA 320 ms 28504 KB
random_25.txt WA 54 ms 3552 KB
sample_01.txt AC 3 ms 3436 KB
sample_02.txt WA 2 ms 3560 KB
sample_03.txt WA 2 ms 3404 KB