This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |