# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
789201 | 2023-07-21T07:34:16 Z | 반딧불(#10041) | Cookies (JOI23_cookies) | C++17 | 2 ms | 1236 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; int n, k; int a[15002], b[15002]; int DP[502][502]; vector<vector<int> > ans; int cnt; void track(int x, int y){ if(!x) return; if(DP[x-1][y] == DP[x][y]){ track(x-1, y); return; } ans.push_back(vector<int> ()); for(int i=0; i<b[x]; i++) ans.back().push_back(++cnt); track(x, y-b[x]); } int main(){ scanf("%d", &n); for(int i=1; i<=n; i++) scanf("%d", &a[i]); scanf("%d", &k); for(int i=1; i<=k; i++) scanf("%d", &b[i]); for(int i=0; i<=k; i++) for(int j=0; j<=n; j++) DP[i][j] = 1e9; DP[0][0] = 0; for(int i=1; i<=k; i++){ for(int j=0; j<=n; j++) DP[i][j] = DP[i-1][j]; for(int j=0; j+b[i]<=n; j++) DP[i][j+b[i]] = min(DP[i][j+b[i]], DP[i][j] + 1); } if(DP[k][n] == 1e9){ printf("-1"); return 0; } track(k, n); printf("%d\n", (int)ans.size()); for(auto p: ans){ printf("%d ", (int)p.size()); for(auto x: p) printf("%d ", x); puts(""); } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
7 | Correct | 0 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 340 KB | Output is correct |
9 | Correct | 0 ms | 212 KB | Output is correct |
10 | Correct | 2 ms | 1236 KB | Output is correct |
11 | Correct | 1 ms | 724 KB | Output is correct |
12 | Correct | 1 ms | 340 KB | Output is correct |
13 | Correct | 1 ms | 468 KB | Output is correct |
14 | Correct | 1 ms | 724 KB | Output is correct |
15 | Correct | 1 ms | 724 KB | Output is correct |
16 | Correct | 1 ms | 724 KB | Output is correct |
17 | Correct | 0 ms | 212 KB | Output is correct |
18 | Correct | 1 ms | 212 KB | Output is correct |
19 | Correct | 0 ms | 212 KB | Output is correct |
20 | Correct | 1 ms | 340 KB | Output is correct |
21 | Correct | 1 ms | 468 KB | Output is correct |
22 | Correct | 1 ms | 724 KB | Output is correct |
23 | Correct | 1 ms | 724 KB | Output is correct |
24 | Correct | 0 ms | 340 KB | Output is correct |
25 | Correct | 0 ms | 340 KB | Output is correct |
26 | Correct | 1 ms | 340 KB | Output is correct |
27 | Correct | 0 ms | 340 KB | Output is correct |
28 | Correct | 1 ms | 596 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 340 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
7 | Incorrect | 0 ms | 212 KB | Number of cookies does not match with A_i |
8 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 308 KB | Output is correct |
4 | Correct | 1 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 312 KB | Output is correct |
6 | Correct | 1 ms | 212 KB | Output is correct |
7 | Correct | 1 ms | 340 KB | Output is correct |
8 | Correct | 1 ms | 212 KB | Output is correct |
9 | Incorrect | 1 ms | 312 KB | Number of cookies does not match with A_i |
10 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
7 | Correct | 0 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 340 KB | Output is correct |
9 | Correct | 0 ms | 212 KB | Output is correct |
10 | Correct | 2 ms | 1236 KB | Output is correct |
11 | Correct | 1 ms | 724 KB | Output is correct |
12 | Correct | 1 ms | 340 KB | Output is correct |
13 | Correct | 1 ms | 468 KB | Output is correct |
14 | Correct | 1 ms | 724 KB | Output is correct |
15 | Correct | 1 ms | 724 KB | Output is correct |
16 | Correct | 1 ms | 724 KB | Output is correct |
17 | Correct | 0 ms | 212 KB | Output is correct |
18 | Correct | 1 ms | 212 KB | Output is correct |
19 | Correct | 0 ms | 212 KB | Output is correct |
20 | Correct | 1 ms | 340 KB | Output is correct |
21 | Correct | 1 ms | 468 KB | Output is correct |
22 | Correct | 1 ms | 724 KB | Output is correct |
23 | Correct | 1 ms | 724 KB | Output is correct |
24 | Correct | 0 ms | 340 KB | Output is correct |
25 | Correct | 0 ms | 340 KB | Output is correct |
26 | Correct | 1 ms | 340 KB | Output is correct |
27 | Correct | 0 ms | 340 KB | Output is correct |
28 | Correct | 1 ms | 596 KB | Output is correct |
29 | Correct | 0 ms | 212 KB | Output is correct |
30 | Correct | 0 ms | 212 KB | Output is correct |
31 | Correct | 1 ms | 308 KB | Output is correct |
32 | Correct | 1 ms | 212 KB | Output is correct |
33 | Correct | 1 ms | 312 KB | Output is correct |
34 | Correct | 1 ms | 212 KB | Output is correct |
35 | Correct | 1 ms | 340 KB | Output is correct |
36 | Correct | 1 ms | 212 KB | Output is correct |
37 | Incorrect | 1 ms | 312 KB | Number of cookies does not match with A_i |
38 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
7 | Correct | 0 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 340 KB | Output is correct |
9 | Correct | 0 ms | 212 KB | Output is correct |
10 | Correct | 2 ms | 1236 KB | Output is correct |
11 | Correct | 1 ms | 724 KB | Output is correct |
12 | Correct | 1 ms | 340 KB | Output is correct |
13 | Correct | 1 ms | 468 KB | Output is correct |
14 | Correct | 1 ms | 724 KB | Output is correct |
15 | Correct | 1 ms | 724 KB | Output is correct |
16 | Correct | 1 ms | 724 KB | Output is correct |
17 | Correct | 0 ms | 212 KB | Output is correct |
18 | Correct | 1 ms | 212 KB | Output is correct |
19 | Correct | 0 ms | 212 KB | Output is correct |
20 | Correct | 1 ms | 340 KB | Output is correct |
21 | Correct | 1 ms | 468 KB | Output is correct |
22 | Correct | 1 ms | 724 KB | Output is correct |
23 | Correct | 1 ms | 724 KB | Output is correct |
24 | Correct | 0 ms | 340 KB | Output is correct |
25 | Correct | 0 ms | 340 KB | Output is correct |
26 | Correct | 1 ms | 340 KB | Output is correct |
27 | Correct | 0 ms | 340 KB | Output is correct |
28 | Correct | 1 ms | 596 KB | Output is correct |
29 | Correct | 0 ms | 212 KB | Output is correct |
30 | Correct | 0 ms | 212 KB | Output is correct |
31 | Correct | 1 ms | 308 KB | Output is correct |
32 | Correct | 1 ms | 212 KB | Output is correct |
33 | Correct | 1 ms | 312 KB | Output is correct |
34 | Correct | 1 ms | 212 KB | Output is correct |
35 | Correct | 1 ms | 340 KB | Output is correct |
36 | Correct | 1 ms | 212 KB | Output is correct |
37 | Incorrect | 1 ms | 312 KB | Number of cookies does not match with A_i |
38 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
7 | Correct | 0 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 340 KB | Output is correct |
9 | Correct | 0 ms | 212 KB | Output is correct |
10 | Correct | 2 ms | 1236 KB | Output is correct |
11 | Correct | 1 ms | 724 KB | Output is correct |
12 | Correct | 1 ms | 340 KB | Output is correct |
13 | Correct | 1 ms | 468 KB | Output is correct |
14 | Correct | 1 ms | 724 KB | Output is correct |
15 | Correct | 1 ms | 724 KB | Output is correct |
16 | Correct | 1 ms | 724 KB | Output is correct |
17 | Correct | 0 ms | 212 KB | Output is correct |
18 | Correct | 1 ms | 212 KB | Output is correct |
19 | Correct | 0 ms | 212 KB | Output is correct |
20 | Correct | 1 ms | 340 KB | Output is correct |
21 | Correct | 1 ms | 468 KB | Output is correct |
22 | Correct | 1 ms | 724 KB | Output is correct |
23 | Correct | 1 ms | 724 KB | Output is correct |
24 | Correct | 0 ms | 340 KB | Output is correct |
25 | Correct | 0 ms | 340 KB | Output is correct |
26 | Correct | 1 ms | 340 KB | Output is correct |
27 | Correct | 0 ms | 340 KB | Output is correct |
28 | Correct | 1 ms | 596 KB | Output is correct |
29 | Correct | 0 ms | 212 KB | Output is correct |
30 | Correct | 1 ms | 212 KB | Output is correct |
31 | Correct | 0 ms | 212 KB | Output is correct |
32 | Correct | 0 ms | 212 KB | Output is correct |
33 | Correct | 0 ms | 340 KB | Output is correct |
34 | Correct | 0 ms | 212 KB | Output is correct |
35 | Incorrect | 0 ms | 212 KB | Number of cookies does not match with A_i |
36 | Halted | 0 ms | 0 KB | - |