Submission #544665

#TimeUsernameProblemLanguageResultExecution timeMemory
544665pokmui9909택배 (KOI13_delivery)C++17
100 / 100
18 ms608 KiB
#include <bits/stdc++.h> using namespace std; struct package { int s, e, cnt; }; int main() { cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false); int n, c; cin >> n >> c; int m; cin >> m; package ar[10001]; for(int i = 0; i < m; i++) cin >> ar[i].s >> ar[i].e >> ar[i].cnt; sort(ar, ar + m, [](package a, package b) -> bool { if(a.e != b.e) return a.e < b.e; else return a.s > b.s; }); int truck[10001] = {}; int ans = 0; for(int i = 0; i < m; i++) { int box = 0; for(int j = ar[i].s; j < ar[i].e; j++) box = max(box, truck[j]); int k = min(c - box, ar[i].cnt); ans += k; for(int j = ar[i].s; j < ar[i].e; j++) truck[j] += k; } cout << ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...