답안 #768520

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
768520 2023-06-28T08:41:50 Z nguyentunglam Two Dishes (JOI19_dishes) C++17
10 / 100
29 ms 32144 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];
        a[i] += a[i - 1];
    }
    for(int i = 1; i <= m; i++) {
        cin >> b[i] >> t[i] >> 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);
      |         ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 3 ms 732 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 31956 KB Output is correct
2 Correct 11 ms 31956 KB Output is correct
3 Correct 12 ms 31952 KB Output is correct
4 Correct 11 ms 31892 KB Output is correct
5 Correct 11 ms 31956 KB Output is correct
6 Correct 11 ms 31956 KB Output is correct
7 Correct 11 ms 31960 KB Output is correct
8 Correct 12 ms 31876 KB Output is correct
9 Correct 12 ms 31956 KB Output is correct
10 Correct 11 ms 31948 KB Output is correct
11 Correct 12 ms 31952 KB Output is correct
12 Correct 12 ms 31976 KB Output is correct
13 Correct 14 ms 31912 KB Output is correct
14 Correct 12 ms 31924 KB Output is correct
15 Correct 12 ms 31956 KB Output is correct
16 Correct 12 ms 31916 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 31956 KB Output is correct
2 Correct 11 ms 31956 KB Output is correct
3 Correct 12 ms 31952 KB Output is correct
4 Correct 11 ms 31892 KB Output is correct
5 Correct 11 ms 31956 KB Output is correct
6 Correct 11 ms 31956 KB Output is correct
7 Correct 11 ms 31960 KB Output is correct
8 Correct 12 ms 31876 KB Output is correct
9 Correct 12 ms 31956 KB Output is correct
10 Correct 11 ms 31948 KB Output is correct
11 Correct 12 ms 31952 KB Output is correct
12 Correct 12 ms 31976 KB Output is correct
13 Correct 14 ms 31912 KB Output is correct
14 Correct 12 ms 31924 KB Output is correct
15 Correct 12 ms 31956 KB Output is correct
16 Correct 12 ms 31916 KB Output is correct
17 Correct 26 ms 32096 KB Output is correct
18 Correct 26 ms 32052 KB Output is correct
19 Correct 27 ms 32144 KB Output is correct
20 Correct 29 ms 32116 KB Output is correct
21 Correct 26 ms 32036 KB Output is correct
22 Correct 26 ms 32024 KB Output is correct
23 Correct 26 ms 31964 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 31956 KB Output is correct
2 Correct 11 ms 31956 KB Output is correct
3 Correct 12 ms 31952 KB Output is correct
4 Correct 11 ms 31892 KB Output is correct
5 Correct 11 ms 31956 KB Output is correct
6 Correct 11 ms 31956 KB Output is correct
7 Correct 11 ms 31960 KB Output is correct
8 Correct 12 ms 31876 KB Output is correct
9 Correct 12 ms 31956 KB Output is correct
10 Correct 11 ms 31948 KB Output is correct
11 Correct 12 ms 31952 KB Output is correct
12 Correct 12 ms 31976 KB Output is correct
13 Correct 14 ms 31912 KB Output is correct
14 Correct 12 ms 31924 KB Output is correct
15 Correct 12 ms 31956 KB Output is correct
16 Correct 12 ms 31916 KB Output is correct
17 Correct 26 ms 32096 KB Output is correct
18 Correct 26 ms 32052 KB Output is correct
19 Correct 27 ms 32144 KB Output is correct
20 Correct 29 ms 32116 KB Output is correct
21 Correct 26 ms 32036 KB Output is correct
22 Correct 26 ms 32024 KB Output is correct
23 Correct 26 ms 31964 KB Output is correct
24 Runtime error 2 ms 728 KB Execution killed with signal 11
25 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 31956 KB Output is correct
2 Correct 11 ms 31956 KB Output is correct
3 Correct 12 ms 31952 KB Output is correct
4 Correct 11 ms 31892 KB Output is correct
5 Correct 11 ms 31956 KB Output is correct
6 Correct 11 ms 31956 KB Output is correct
7 Correct 11 ms 31960 KB Output is correct
8 Correct 12 ms 31876 KB Output is correct
9 Correct 12 ms 31956 KB Output is correct
10 Correct 11 ms 31948 KB Output is correct
11 Correct 12 ms 31952 KB Output is correct
12 Correct 12 ms 31976 KB Output is correct
13 Correct 14 ms 31912 KB Output is correct
14 Correct 12 ms 31924 KB Output is correct
15 Correct 12 ms 31956 KB Output is correct
16 Correct 12 ms 31916 KB Output is correct
17 Correct 26 ms 32096 KB Output is correct
18 Correct 26 ms 32052 KB Output is correct
19 Correct 27 ms 32144 KB Output is correct
20 Correct 29 ms 32116 KB Output is correct
21 Correct 26 ms 32036 KB Output is correct
22 Correct 26 ms 32024 KB Output is correct
23 Correct 26 ms 31964 KB Output is correct
24 Runtime error 2 ms 728 KB Execution killed with signal 11
25 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 31956 KB Output is correct
2 Correct 11 ms 31956 KB Output is correct
3 Correct 12 ms 31952 KB Output is correct
4 Correct 11 ms 31892 KB Output is correct
5 Correct 11 ms 31956 KB Output is correct
6 Correct 11 ms 31956 KB Output is correct
7 Correct 11 ms 31960 KB Output is correct
8 Correct 12 ms 31876 KB Output is correct
9 Correct 12 ms 31956 KB Output is correct
10 Correct 11 ms 31948 KB Output is correct
11 Correct 12 ms 31952 KB Output is correct
12 Correct 12 ms 31976 KB Output is correct
13 Correct 14 ms 31912 KB Output is correct
14 Correct 12 ms 31924 KB Output is correct
15 Correct 12 ms 31956 KB Output is correct
16 Correct 12 ms 31916 KB Output is correct
17 Correct 26 ms 32096 KB Output is correct
18 Correct 26 ms 32052 KB Output is correct
19 Correct 27 ms 32144 KB Output is correct
20 Correct 29 ms 32116 KB Output is correct
21 Correct 26 ms 32036 KB Output is correct
22 Correct 26 ms 32024 KB Output is correct
23 Correct 26 ms 31964 KB Output is correct
24 Runtime error 2 ms 728 KB Execution killed with signal 11
25 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 3 ms 732 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 3 ms 732 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -