#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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
468 KB |
Output is correct |
2 |
Correct |
1 ms |
472 KB |
Output is correct |
3 |
Correct |
1 ms |
472 KB |
Output is correct |
4 |
Correct |
1 ms |
476 KB |
Output is correct |
5 |
Correct |
1 ms |
480 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
468 KB |
Output is correct |
2 |
Correct |
1 ms |
468 KB |
Output is correct |
3 |
Correct |
1 ms |
468 KB |
Output is correct |
4 |
Correct |
1 ms |
468 KB |
Output is correct |
5 |
Correct |
1 ms |
468 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
468 KB |
Output is correct |
2 |
Correct |
1 ms |
476 KB |
Output is correct |
3 |
Correct |
1 ms |
468 KB |
Output is correct |
4 |
Correct |
1 ms |
468 KB |
Output is correct |
5 |
Correct |
1 ms |
468 KB |
Output is correct |
6 |
Correct |
1 ms |
468 KB |
Output is correct |
7 |
Correct |
1 ms |
468 KB |
Output is correct |
8 |
Correct |
1 ms |
468 KB |
Output is correct |
9 |
Correct |
1 ms |
468 KB |
Output is correct |
10 |
Correct |
1 ms |
468 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
468 KB |
Output is correct |
2 |
Correct |
1 ms |
468 KB |
Output is correct |
3 |
Correct |
1 ms |
468 KB |
Output is correct |
4 |
Correct |
1 ms |
468 KB |
Output is correct |
5 |
Correct |
1 ms |
468 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
484 KB |
Output is correct |
2 |
Correct |
1 ms |
468 KB |
Output is correct |
3 |
Correct |
15 ms |
608 KB |
Output is correct |
4 |
Correct |
16 ms |
468 KB |
Output is correct |
5 |
Correct |
18 ms |
604 KB |
Output is correct |