# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
123283 | 2019-07-01T05:43:08 Z | 이온조(#3019) | Two Dishes (JOI19_dishes) | C++14 | 220 ms | 12408 KB |
#include <bits/stdc++.h> using namespace std; const long long INF = 1LL * 1e18; int A[1000009], B[1000009], P[1000009], Q[1000009]; long long S[1000009], T[1000009], PB[1000009], PQ[1000009]; int main() { int N, M; scanf("%d%d",&N,&M); for(int i=1; i<=N; i++) scanf("%d%lld%d", &A[i], &S[i], &P[i]); for(int i=1; i<=M; i++) scanf("%d%lld%d", &B[i], &T[i], &Q[i]); bool S1 = (S[1] == T[1]); for(int i=2; i<=N; i++) if(S[i] != S[i-1]) S1 = 0; for(int i=2; i<=M; i++) if(T[i] != T[i-1]) S1 = 0; if(S1) { for(int i=1; i<=M; i++) PB[i] = PB[i-1] + B[i], PQ[i] = PQ[i-1] + Q[i]; long long x = S[1], ans = -INF, s = 0; for(int i=1; i<=N+1; i++) { if(x <= 0) break; int l = 0, r = M; while(l <= r) { int m = l+r >> 1; if(PB[m] <= x) l = m+1; else r = m-1; } if(i == N+1 || PB[l-1] + A[i] > x) ans = max(ans, s + PQ[l-1]); if(i == N+1) break; x -= A[i]; s += P[i]; } printf("%lld", ans); } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 220 ms | 11728 KB | Output is correct |
2 | Correct | 215 ms | 11384 KB | Output is correct |
3 | Correct | 212 ms | 11500 KB | Output is correct |
4 | Correct | 207 ms | 11560 KB | Output is correct |
5 | Correct | 2 ms | 376 KB | Output is correct |
6 | Correct | 213 ms | 11000 KB | Output is correct |
7 | Correct | 104 ms | 9080 KB | Output is correct |
8 | Correct | 103 ms | 6136 KB | Output is correct |
9 | Correct | 212 ms | 11244 KB | Output is correct |
10 | Correct | 155 ms | 12280 KB | Output is correct |
11 | Correct | 146 ms | 12408 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 5 ms | 376 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 5 ms | 376 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 5 ms | 376 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 5 ms | 376 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 5 ms | 376 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 220 ms | 11728 KB | Output is correct |
2 | Correct | 215 ms | 11384 KB | Output is correct |
3 | Correct | 212 ms | 11500 KB | Output is correct |
4 | Correct | 207 ms | 11560 KB | Output is correct |
5 | Correct | 2 ms | 376 KB | Output is correct |
6 | Correct | 213 ms | 11000 KB | Output is correct |
7 | Correct | 104 ms | 9080 KB | Output is correct |
8 | Correct | 103 ms | 6136 KB | Output is correct |
9 | Correct | 212 ms | 11244 KB | Output is correct |
10 | Correct | 155 ms | 12280 KB | Output is correct |
11 | Correct | 146 ms | 12408 KB | Output is correct |
12 | Incorrect | 5 ms | 376 KB | Output isn't correct |
13 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 220 ms | 11728 KB | Output is correct |
2 | Correct | 215 ms | 11384 KB | Output is correct |
3 | Correct | 212 ms | 11500 KB | Output is correct |
4 | Correct | 207 ms | 11560 KB | Output is correct |
5 | Correct | 2 ms | 376 KB | Output is correct |
6 | Correct | 213 ms | 11000 KB | Output is correct |
7 | Correct | 104 ms | 9080 KB | Output is correct |
8 | Correct | 103 ms | 6136 KB | Output is correct |
9 | Correct | 212 ms | 11244 KB | Output is correct |
10 | Correct | 155 ms | 12280 KB | Output is correct |
11 | Correct | 146 ms | 12408 KB | Output is correct |
12 | Incorrect | 5 ms | 376 KB | Output isn't correct |
13 | Halted | 0 ms | 0 KB | - |