Submission #140581

#TimeUsernameProblemLanguageResultExecution timeMemory
140581khrbuddy03택배 (KOI13_delivery)C++14
100 / 100
18 ms888 KiB
#include <bits/stdc++.h> using namespace std; typedef pair<pair<int, int>, int> vil; int n, c, m, load[2009]; vector<vil> vils; bool cmp(const vil& v1, const vil& v2) { if (v1.first.second == v2.first.second) return v1.first.first < v2.first.first; return v1.first.second < v2.first.second; } int main() { // freopen("input.txt", "r", stdin); ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> c >> m; for (int i = 0; i < m; i++) { int a, b, c; cin >> a >> b >> c; vils.push_back(make_pair(make_pair(a, b), c)); } sort(vils.begin(), vils.end(), cmp); int ans = 0; for (int i = 0; i < m; i++) { int mbox = 0; for (int j = vils[i].first.first; j < vils[i].first.second; j++) { mbox = max(mbox, load[j]); } int tmp = min(vils[i].second, c - mbox); for (int j = vils[i].first.first; j < vils[i].first.second; j++) { load[j] += tmp; } ans += tmp; } cout << ans << '\n'; }
#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...