# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
456400 | 2021-08-06T16:17:16 Z | ntabc05101 | Go (COCI16_go) | C++14 | 1 ms | 312 KB |
#include<bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; #define taskname "" int main() { if (fopen(taskname".inp", "r")) { freopen(taskname".inp", "r", stdin); freopen(taskname".out", "w", stdout); } cin.tie(0)->sync_with_stdio(0); int n, k, m; cin >> n >> k >> m; array<int, 3> a[m + 1]; for (int i = 1; i <= m; i++) { cin >> a[i][0] >> a[i][1] >> a[i][2]; } a[0] = {k, 0, 0}; sort(a + 1, a + m + 1, [&](auto const& x, auto const& y) { return x[1] + x[2] < y[1] + y[2]; }); int dp[m + 1][2001]; for (int i = 0; i <= m; i++) { for (int j = 0; j <= 2000; j++) { dp[i][j] = -mod; } } dp[0][0] = 0; int res = 0; for (int i = 1; i <= m; i++) { for (int j = 0; j < i; j++) { int z = abs(a[i][0] - a[j][0]) + 1; for (int k = z; k <= a[i][2]; k++) { dp[i][k] = max(dp[i][k], dp[j][k - z] + a[i][1]); res = max(res, dp[i][k]); } } } cout << res << endl; return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 204 KB | Output isn't correct |
2 | Incorrect | 1 ms | 204 KB | Output isn't correct |
3 | Incorrect | 0 ms | 204 KB | Output isn't correct |
4 | Incorrect | 0 ms | 204 KB | Output isn't correct |
5 | Incorrect | 0 ms | 204 KB | Output isn't correct |
6 | Incorrect | 0 ms | 204 KB | Output isn't correct |
7 | Incorrect | 1 ms | 204 KB | Output isn't correct |
8 | Incorrect | 0 ms | 312 KB | Output isn't correct |
9 | Incorrect | 0 ms | 204 KB | Output isn't correct |
10 | Incorrect | 0 ms | 204 KB | Output isn't correct |
11 | Incorrect | 1 ms | 204 KB | Output isn't correct |
12 | Incorrect | 1 ms | 204 KB | Output isn't correct |
13 | Incorrect | 0 ms | 308 KB | Output isn't correct |
14 | Incorrect | 0 ms | 204 KB | Output isn't correct |
15 | Incorrect | 1 ms | 204 KB | Output isn't correct |
16 | Incorrect | 1 ms | 204 KB | Output isn't correct |
17 | Incorrect | 0 ms | 204 KB | Output isn't correct |
18 | Incorrect | 0 ms | 204 KB | Output isn't correct |
19 | Incorrect | 0 ms | 216 KB | Output isn't correct |
20 | Incorrect | 1 ms | 204 KB | Output isn't correct |
21 | Incorrect | 0 ms | 204 KB | Output isn't correct |
22 | Incorrect | 1 ms | 204 KB | Output isn't correct |
23 | Incorrect | 0 ms | 204 KB | Output isn't correct |
24 | Incorrect | 1 ms | 204 KB | Output isn't correct |
25 | Incorrect | 1 ms | 308 KB | Output isn't correct |