Submission #18135538


Source Code Expand

#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

typedef long long int ll;

int main() {
    ll n, w; cin >> n >> w;
    vector <ll> history(2*100000+1, 0);

    for (int i = 0; i < n; i++) {
        ll s,t, p; cin >> s >> t >> p;
        history[s] += p;
        history[t] -= p;
    }
    bool ans = true;
    for (int i = 0; i <(int)history.size(); i++) {
        if (i > 0) {
            history[i] = history[i-1] + history[i];
        }
        if (history[i] > w) {
            ans = false;
        }
    }
    if (ans) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    
    return 0;
}

Submission Info

Submission Time
Task D - Water Heater
User tomoya
Language C++ (Clang 10.0.0)
Score 400
Code Size 694 Byte
Status AC
Exec Time 319 ms
Memory 4464 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 3
AC × 18
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
All hand_01.txt, hand_02.txt, hand_03.txt, hand_04.txt, hand_05.txt, 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, sample_01.txt, sample_02.txt, sample_03.txt
Case Name Status Exec Time Memory
hand_01.txt AC 281 ms 4280 KiB
hand_02.txt AC 218 ms 4308 KiB
hand_03.txt AC 279 ms 4308 KiB
hand_04.txt AC 221 ms 4348 KiB
hand_05.txt AC 3 ms 4316 KiB
random_01.txt AC 318 ms 4348 KiB
random_02.txt AC 319 ms 4464 KiB
random_03.txt AC 318 ms 4324 KiB
random_04.txt AC 316 ms 4312 KiB
random_05.txt AC 317 ms 4276 KiB
random_06.txt AC 318 ms 4368 KiB
random_07.txt AC 315 ms 4348 KiB
random_08.txt AC 317 ms 4344 KiB
random_09.txt AC 316 ms 4308 KiB
random_10.txt AC 315 ms 4340 KiB
sample_01.txt AC 4 ms 4460 KiB
sample_02.txt AC 4 ms 4460 KiB
sample_03.txt AC 4 ms 4296 KiB