# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
768981 | 2023-06-29T03:57:36 Z | nguyentunglam | Two Dishes (JOI19_dishes) | C++17 | 8 ms | 596 KB |
#include<bits/stdc++.h> #define fi first #define se second #define endl "\n" #define ii pair<int, int> using namespace std; const int N = 2010; long long a[N], b[N], s[N], t[N], p[N], q[N]; long long f[N]; vector<int> event[N]; int n, m; void up(int j, int x) { long long sum = 0; for(int i = j; i >= 1; i--) { if (x <= t[i]) sum += q[i]; f[j] = max(f[j], f[i - 1] + sum); } } int main() { #define task "" cin.tie(0) -> sync_with_stdio(0); if (fopen ("task.inp", "r")) { freopen ("task.inp", "r", stdin); freopen ("task.out", "w", stdout); } if (fopen (task".inp", "r")) { freopen (task".inp", "r", stdin); freopen (task".out", "w", stdout); } cin >> n >> m; for(int i = 1; i <= n; i++) { cin >> a[i] >> s[i] >> p[i]; p[i] = p[i]; a[i] += a[i - 1]; } for(int i = 1; i <= m; i++) { cin >> b[i] >> t[i] >> q[i]; q[i] = q[i]; b[i] += b[i - 1]; } for(int i = 1; i <= n; i++) { int l = 0, r = m, last = -1; while (l <= r) { int mid = l + r >> 1; if (a[i] + b[mid] <= s[i]) { last = mid; l = mid + 1; } else r = mid - 1; } s[i] = last; } for(int i = 1; i <= m; i++) { int l = 0, r = n, last = -1; while (l <= r) { int mid = l + r >> 1; if (b[i] + a[mid] <= t[i]) { last = mid; l = mid + 1; } else r = mid - 1; } t[i] = last; if (last >= 0) event[last].push_back(i); } for(int i = 1; i <= m; i++) f[i] = -1e9; for(int i = 1; i <= n; i++) { for(int &j : event[i - 1]) up(j, i - 1); up(s[i] + 1, i - 1); for(int j = 0; j <= s[i]; j++) f[j] += p[i]; // for(int j = 0; j <= m; j++) cout << f[j] << " "; } up(m, n); cout << f[m]; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 2 ms | 596 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 0 ms | 340 KB | Output is correct |
3 | Correct | 0 ms | 340 KB | Output is correct |
4 | Correct | 1 ms | 340 KB | Output is correct |
5 | Correct | 1 ms | 340 KB | Output is correct |
6 | Correct | 0 ms | 340 KB | Output is correct |
7 | Correct | 0 ms | 340 KB | Output is correct |
8 | Correct | 1 ms | 340 KB | Output is correct |
9 | Correct | 0 ms | 340 KB | Output is correct |
10 | Correct | 1 ms | 340 KB | Output is correct |
11 | Correct | 0 ms | 340 KB | Output is correct |
12 | Correct | 0 ms | 340 KB | Output is correct |
13 | Correct | 0 ms | 340 KB | Output is correct |
14 | Correct | 1 ms | 340 KB | Output is correct |
15 | Correct | 0 ms | 340 KB | Output is correct |
16 | Correct | 0 ms | 340 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 0 ms | 340 KB | Output is correct |
3 | Correct | 0 ms | 340 KB | Output is correct |
4 | Correct | 1 ms | 340 KB | Output is correct |
5 | Correct | 1 ms | 340 KB | Output is correct |
6 | Correct | 0 ms | 340 KB | Output is correct |
7 | Correct | 0 ms | 340 KB | Output is correct |
8 | Correct | 1 ms | 340 KB | Output is correct |
9 | Correct | 0 ms | 340 KB | Output is correct |
10 | Correct | 1 ms | 340 KB | Output is correct |
11 | Correct | 0 ms | 340 KB | Output is correct |
12 | Correct | 0 ms | 340 KB | Output is correct |
13 | Correct | 0 ms | 340 KB | Output is correct |
14 | Correct | 1 ms | 340 KB | Output is correct |
15 | Correct | 0 ms | 340 KB | Output is correct |
16 | Correct | 0 ms | 340 KB | Output is correct |
17 | Correct | 1 ms | 468 KB | Output is correct |
18 | Correct | 6 ms | 468 KB | Output is correct |
19 | Correct | 7 ms | 468 KB | Output is correct |
20 | Correct | 4 ms | 500 KB | Output is correct |
21 | Correct | 8 ms | 468 KB | Output is correct |
22 | Correct | 7 ms | 468 KB | Output is correct |
23 | Correct | 7 ms | 468 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 0 ms | 340 KB | Output is correct |
3 | Correct | 0 ms | 340 KB | Output is correct |
4 | Correct | 1 ms | 340 KB | Output is correct |
5 | Correct | 1 ms | 340 KB | Output is correct |
6 | Correct | 0 ms | 340 KB | Output is correct |
7 | Correct | 0 ms | 340 KB | Output is correct |
8 | Correct | 1 ms | 340 KB | Output is correct |
9 | Correct | 0 ms | 340 KB | Output is correct |
10 | Correct | 1 ms | 340 KB | Output is correct |
11 | Correct | 0 ms | 340 KB | Output is correct |
12 | Correct | 0 ms | 340 KB | Output is correct |
13 | Correct | 0 ms | 340 KB | Output is correct |
14 | Correct | 1 ms | 340 KB | Output is correct |
15 | Correct | 0 ms | 340 KB | Output is correct |
16 | Correct | 0 ms | 340 KB | Output is correct |
17 | Correct | 1 ms | 468 KB | Output is correct |
18 | Correct | 6 ms | 468 KB | Output is correct |
19 | Correct | 7 ms | 468 KB | Output is correct |
20 | Correct | 4 ms | 500 KB | Output is correct |
21 | Correct | 8 ms | 468 KB | Output is correct |
22 | Correct | 7 ms | 468 KB | Output is correct |
23 | Correct | 7 ms | 468 KB | Output is correct |
24 | Runtime error | 1 ms | 596 KB | Execution killed with signal 11 |
25 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 0 ms | 340 KB | Output is correct |
3 | Correct | 0 ms | 340 KB | Output is correct |
4 | Correct | 1 ms | 340 KB | Output is correct |
5 | Correct | 1 ms | 340 KB | Output is correct |
6 | Correct | 0 ms | 340 KB | Output is correct |
7 | Correct | 0 ms | 340 KB | Output is correct |
8 | Correct | 1 ms | 340 KB | Output is correct |
9 | Correct | 0 ms | 340 KB | Output is correct |
10 | Correct | 1 ms | 340 KB | Output is correct |
11 | Correct | 0 ms | 340 KB | Output is correct |
12 | Correct | 0 ms | 340 KB | Output is correct |
13 | Correct | 0 ms | 340 KB | Output is correct |
14 | Correct | 1 ms | 340 KB | Output is correct |
15 | Correct | 0 ms | 340 KB | Output is correct |
16 | Correct | 0 ms | 340 KB | Output is correct |
17 | Correct | 1 ms | 468 KB | Output is correct |
18 | Correct | 6 ms | 468 KB | Output is correct |
19 | Correct | 7 ms | 468 KB | Output is correct |
20 | Correct | 4 ms | 500 KB | Output is correct |
21 | Correct | 8 ms | 468 KB | Output is correct |
22 | Correct | 7 ms | 468 KB | Output is correct |
23 | Correct | 7 ms | 468 KB | Output is correct |
24 | Runtime error | 1 ms | 596 KB | Execution killed with signal 11 |
25 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 0 ms | 340 KB | Output is correct |
3 | Correct | 0 ms | 340 KB | Output is correct |
4 | Correct | 1 ms | 340 KB | Output is correct |
5 | Correct | 1 ms | 340 KB | Output is correct |
6 | Correct | 0 ms | 340 KB | Output is correct |
7 | Correct | 0 ms | 340 KB | Output is correct |
8 | Correct | 1 ms | 340 KB | Output is correct |
9 | Correct | 0 ms | 340 KB | Output is correct |
10 | Correct | 1 ms | 340 KB | Output is correct |
11 | Correct | 0 ms | 340 KB | Output is correct |
12 | Correct | 0 ms | 340 KB | Output is correct |
13 | Correct | 0 ms | 340 KB | Output is correct |
14 | Correct | 1 ms | 340 KB | Output is correct |
15 | Correct | 0 ms | 340 KB | Output is correct |
16 | Correct | 0 ms | 340 KB | Output is correct |
17 | Correct | 1 ms | 468 KB | Output is correct |
18 | Correct | 6 ms | 468 KB | Output is correct |
19 | Correct | 7 ms | 468 KB | Output is correct |
20 | Correct | 4 ms | 500 KB | Output is correct |
21 | Correct | 8 ms | 468 KB | Output is correct |
22 | Correct | 7 ms | 468 KB | Output is correct |
23 | Correct | 7 ms | 468 KB | Output is correct |
24 | Runtime error | 1 ms | 596 KB | Execution killed with signal 11 |
25 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 2 ms | 596 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 2 ms | 596 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |