Submission #768600

# Submission time Handle Problem Language Result Execution time Memory
768600 2023-06-28T09:44:47 Z nguyentunglam Two Dishes (JOI19_dishes) C++17
10 / 100
29 ms 32148 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][N];
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);
    }
    int n, m; cin >> n >> m;
    for(int i = 1; i <= n; i++) {
        cin >> a[i] >> s[i] >> p[i];
        p[i] = max(0LL, p[i]);
        a[i] += a[i - 1];
    }
    for(int i = 1; i <= m; i++) {
        cin >> b[i] >> t[i] >> q[i];
        q[i] = max(0LL, q[i]);
        b[i] += b[i - 1];
    }
    memset(f, -127, sizeof(f));
    f[0][0] = 0;
    for(int i = 0; i <= n; i++) for(int j = 0; j <= m; j++) {
        if (i == 0 && j == 0) continue;
        if (i) f[i][j] = max(f[i][j], f[i - 1][j] + (a[i] + b[j] <= s[i]) * p[i]);
        if (j) f[i][j] = max(f[i][j], f[i][j - 1] + (a[i] + b[j] <= t[j]) * q[j]);
    }
    cout << f[n][m];
}

Compilation message

dishes.cpp: In function 'int main()':
dishes.cpp:14:17: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |         freopen ("task.inp", "r", stdin);
      |         ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
dishes.cpp:15:17: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |         freopen ("task.out", "w", stdout);
      |         ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
dishes.cpp:18:17: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |         freopen (task".inp", "r", stdin);
      |         ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
dishes.cpp:19:17: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |         freopen (task".out", "w", stdout);
      |         ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 856 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 13 ms 31864 KB Output is correct
2 Correct 14 ms 31956 KB Output is correct
3 Correct 13 ms 31872 KB Output is correct
4 Correct 13 ms 31956 KB Output is correct
5 Correct 12 ms 31952 KB Output is correct
6 Correct 13 ms 31956 KB Output is correct
7 Correct 14 ms 31956 KB Output is correct
8 Correct 13 ms 31956 KB Output is correct
9 Correct 13 ms 31880 KB Output is correct
10 Correct 13 ms 31936 KB Output is correct
11 Correct 12 ms 31908 KB Output is correct
12 Correct 14 ms 31928 KB Output is correct
13 Correct 15 ms 31948 KB Output is correct
14 Correct 13 ms 31896 KB Output is correct
15 Correct 13 ms 31956 KB Output is correct
16 Correct 12 ms 31932 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 13 ms 31864 KB Output is correct
2 Correct 14 ms 31956 KB Output is correct
3 Correct 13 ms 31872 KB Output is correct
4 Correct 13 ms 31956 KB Output is correct
5 Correct 12 ms 31952 KB Output is correct
6 Correct 13 ms 31956 KB Output is correct
7 Correct 14 ms 31956 KB Output is correct
8 Correct 13 ms 31956 KB Output is correct
9 Correct 13 ms 31880 KB Output is correct
10 Correct 13 ms 31936 KB Output is correct
11 Correct 12 ms 31908 KB Output is correct
12 Correct 14 ms 31928 KB Output is correct
13 Correct 15 ms 31948 KB Output is correct
14 Correct 13 ms 31896 KB Output is correct
15 Correct 13 ms 31956 KB Output is correct
16 Correct 12 ms 31932 KB Output is correct
17 Correct 29 ms 32132 KB Output is correct
18 Correct 28 ms 32084 KB Output is correct
19 Correct 27 ms 32076 KB Output is correct
20 Correct 27 ms 32084 KB Output is correct
21 Correct 27 ms 32148 KB Output is correct
22 Correct 28 ms 31988 KB Output is correct
23 Correct 27 ms 31956 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 13 ms 31864 KB Output is correct
2 Correct 14 ms 31956 KB Output is correct
3 Correct 13 ms 31872 KB Output is correct
4 Correct 13 ms 31956 KB Output is correct
5 Correct 12 ms 31952 KB Output is correct
6 Correct 13 ms 31956 KB Output is correct
7 Correct 14 ms 31956 KB Output is correct
8 Correct 13 ms 31956 KB Output is correct
9 Correct 13 ms 31880 KB Output is correct
10 Correct 13 ms 31936 KB Output is correct
11 Correct 12 ms 31908 KB Output is correct
12 Correct 14 ms 31928 KB Output is correct
13 Correct 15 ms 31948 KB Output is correct
14 Correct 13 ms 31896 KB Output is correct
15 Correct 13 ms 31956 KB Output is correct
16 Correct 12 ms 31932 KB Output is correct
17 Correct 29 ms 32132 KB Output is correct
18 Correct 28 ms 32084 KB Output is correct
19 Correct 27 ms 32076 KB Output is correct
20 Correct 27 ms 32084 KB Output is correct
21 Correct 27 ms 32148 KB Output is correct
22 Correct 28 ms 31988 KB Output is correct
23 Correct 27 ms 31956 KB Output is correct
24 Runtime error 2 ms 732 KB Execution killed with signal 11
25 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 13 ms 31864 KB Output is correct
2 Correct 14 ms 31956 KB Output is correct
3 Correct 13 ms 31872 KB Output is correct
4 Correct 13 ms 31956 KB Output is correct
5 Correct 12 ms 31952 KB Output is correct
6 Correct 13 ms 31956 KB Output is correct
7 Correct 14 ms 31956 KB Output is correct
8 Correct 13 ms 31956 KB Output is correct
9 Correct 13 ms 31880 KB Output is correct
10 Correct 13 ms 31936 KB Output is correct
11 Correct 12 ms 31908 KB Output is correct
12 Correct 14 ms 31928 KB Output is correct
13 Correct 15 ms 31948 KB Output is correct
14 Correct 13 ms 31896 KB Output is correct
15 Correct 13 ms 31956 KB Output is correct
16 Correct 12 ms 31932 KB Output is correct
17 Correct 29 ms 32132 KB Output is correct
18 Correct 28 ms 32084 KB Output is correct
19 Correct 27 ms 32076 KB Output is correct
20 Correct 27 ms 32084 KB Output is correct
21 Correct 27 ms 32148 KB Output is correct
22 Correct 28 ms 31988 KB Output is correct
23 Correct 27 ms 31956 KB Output is correct
24 Runtime error 2 ms 732 KB Execution killed with signal 11
25 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 13 ms 31864 KB Output is correct
2 Correct 14 ms 31956 KB Output is correct
3 Correct 13 ms 31872 KB Output is correct
4 Correct 13 ms 31956 KB Output is correct
5 Correct 12 ms 31952 KB Output is correct
6 Correct 13 ms 31956 KB Output is correct
7 Correct 14 ms 31956 KB Output is correct
8 Correct 13 ms 31956 KB Output is correct
9 Correct 13 ms 31880 KB Output is correct
10 Correct 13 ms 31936 KB Output is correct
11 Correct 12 ms 31908 KB Output is correct
12 Correct 14 ms 31928 KB Output is correct
13 Correct 15 ms 31948 KB Output is correct
14 Correct 13 ms 31896 KB Output is correct
15 Correct 13 ms 31956 KB Output is correct
16 Correct 12 ms 31932 KB Output is correct
17 Correct 29 ms 32132 KB Output is correct
18 Correct 28 ms 32084 KB Output is correct
19 Correct 27 ms 32076 KB Output is correct
20 Correct 27 ms 32084 KB Output is correct
21 Correct 27 ms 32148 KB Output is correct
22 Correct 28 ms 31988 KB Output is correct
23 Correct 27 ms 31956 KB Output is correct
24 Runtime error 2 ms 732 KB Execution killed with signal 11
25 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 856 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 856 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -