Submission #266296

# Submission time Handle Problem Language Result Execution time Memory
266296 2020-08-15T07:48:44 Z dolphingarlic Two Dishes (JOI19_dishes) C++14
10 / 100
10000 ms 26360 KB
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;

ll a[200001], b[200001], s[200001], t[200001], p[200001], q[200001];
ll dp[2][200001];

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    for (int i = 1; i <= n; i++) {
        cin >> a[i] >> s[i] >> p[i];
        a[i] += a[i - 1];
    }
    for (int i = 1; i <= m; i++) {
        cin >> b[i] >> t[i] >> q[i];
        b[i] += b[i - 1];
    }
    for (int i = 1; i <= m; i++) dp[0][i] = dp[0][i - 1] + q[i] * (b[i] <= t[i]);
    for (int i = 1; i <= n; i++) {
        dp[i & 1][0] = dp[i - 1 & 1][0] + p[i] * (a[i] <= s[i]);
        for (int j = 1; j <= m; j++) {
            dp[i & 1][j] = max(dp[i - 1 & 1][j] + p[i] * (a[i] + b[j] <= s[i]),
                           dp[i & 1][j - 1] + q[j] * (a[i] + b[j] <= t[j]));
        }
    }
    cout << dp[n & 1][m];
    return 0;
}

Compilation message

dishes.cpp: In function 'int main()':
dishes.cpp:23:29: warning: suggest parentheses around '-' in operand of '&' [-Wparentheses]
   23 |         dp[i & 1][0] = dp[i - 1 & 1][0] + p[i] * (a[i] <= s[i]);
      |                           ~~^~~
dishes.cpp:25:37: warning: suggest parentheses around '-' in operand of '&' [-Wparentheses]
   25 |             dp[i & 1][j] = max(dp[i - 1 & 1][j] + p[i] * (a[i] + b[j] <= s[i]),
      |                                   ~~^~~
# Verdict Execution time Memory Grader output
1 Execution timed out 10029 ms 26360 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 512 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 ms 512 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 0 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 512 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 ms 512 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 0 ms 384 KB Output is correct
17 Correct 12 ms 676 KB Output is correct
18 Correct 14 ms 640 KB Output is correct
19 Correct 11 ms 640 KB Output is correct
20 Correct 13 ms 640 KB Output is correct
21 Correct 11 ms 640 KB Output is correct
22 Correct 12 ms 512 KB Output is correct
23 Correct 11 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 512 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 ms 512 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 0 ms 384 KB Output is correct
17 Correct 12 ms 676 KB Output is correct
18 Correct 14 ms 640 KB Output is correct
19 Correct 11 ms 640 KB Output is correct
20 Correct 13 ms 640 KB Output is correct
21 Correct 11 ms 640 KB Output is correct
22 Correct 12 ms 512 KB Output is correct
23 Correct 11 ms 512 KB Output is correct
24 Execution timed out 10024 ms 23368 KB Time limit exceeded
25 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 512 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 ms 512 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 0 ms 384 KB Output is correct
17 Correct 12 ms 676 KB Output is correct
18 Correct 14 ms 640 KB Output is correct
19 Correct 11 ms 640 KB Output is correct
20 Correct 13 ms 640 KB Output is correct
21 Correct 11 ms 640 KB Output is correct
22 Correct 12 ms 512 KB Output is correct
23 Correct 11 ms 512 KB Output is correct
24 Execution timed out 10024 ms 23368 KB Time limit exceeded
25 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 512 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 ms 512 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 0 ms 384 KB Output is correct
17 Correct 12 ms 676 KB Output is correct
18 Correct 14 ms 640 KB Output is correct
19 Correct 11 ms 640 KB Output is correct
20 Correct 13 ms 640 KB Output is correct
21 Correct 11 ms 640 KB Output is correct
22 Correct 12 ms 512 KB Output is correct
23 Correct 11 ms 512 KB Output is correct
24 Execution timed out 10024 ms 23368 KB Time limit exceeded
25 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 10029 ms 26360 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 10029 ms 26360 KB Time limit exceeded
2 Halted 0 ms 0 KB -