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;
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 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... |