# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
572172 |
2022-06-03T21:50:09 Z |
sidon |
Two Dishes (JOI19_dishes) |
C++17 |
|
303 ms |
72664 KB |
#include <bits/stdc++.h>
using namespace std;
#define int long long
int32_t main() {
ios::sync_with_stdio(0), cin.tie(0);
int N, M; cin >> N >> M;
int A[N], S[N], P[N];
int B[M], T[M], Q[M];
for(int i = 0; i < N; ++i) {
cin >> A[i] >> S[i] >> P[i];
if(i) A[i] += A[i-1];
}
for(int i = 0; i < M; ++i) {
cin >> B[i] >> T[i] >> Q[i];
if(i) B[i] += B[i-1];
}
map<int, int> g[N+1] {{{0, 0}}};
int ans {};
for(int i = 0; i < N; ++i) if(S[i] >= A[i]) {
S[i] = upper_bound(B, B + M, S[i] - A[i]) - B;
g[i+1][S[i]] += P[i];
}
for(int i = 0; i < M; ++i) if(T[i] >= B[i]) {
T[i] = upper_bound(A, A + N, T[i] - B[i]) - A;
if(T[i] < N) g[T[i]+1][i] -= Q[i];
ans += Q[i];
}
map<int, int> s {{1, -1e17}};
for(int i = 1; i <= N; ++i) {
g[i][M+1] = 0;
int cur {}, last = 1e17, l {};
auto p = begin(g[i-1]);
for(auto [r, val] : g[i]) cur += val;
for(auto [r, val] : g[i]) {
s[l] += cur;
s[r+1] -= cur;
auto fix = [&](int j) {
auto f = s.upper_bound(j);
while(f != s.end() && f->first <= r && f->second <= 0) {
auto nx = next(f) == end(s) ? r + 1 : next(f)->first;
s[nx] += f->second;
f = s.erase(f);
}
};
if(s[l] < 0) {
s[l+1] += s[l];
s[l] = 0;
fix(l);
}
cur -= last = val;
for(; p != end(g[i-1]) && p->first <= r; p++)
fix(p->first);
l = r + 1;
}
}
for(int i = 0; i <= M; ++i)
ans += s[i];
cout << ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
303 ms |
72664 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
316 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Incorrect |
1 ms |
320 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
316 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Incorrect |
1 ms |
320 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
316 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Incorrect |
1 ms |
320 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
316 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Incorrect |
1 ms |
320 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
316 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Incorrect |
1 ms |
320 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
303 ms |
72664 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
303 ms |
72664 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |