# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
789199 | 2023-07-21T07:31:51 Z | 반딧불(#10041) | Cookies (JOI23_cookies) | C++17 | 1 ms | 312 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; int n, k; int a[15002], b[15002]; bool DP[502][502]; vector<vector<int> > ans; int cnt; void track(int x, int y){ if(!x) return; if(DP[x-1][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]); DP[0][0] = 1; for(int i=1; i<=k; i++){ for(int j=0; j<=n; j++) if(DP[i-1][j]) DP[i][j] = 1; for(int j=0; j+b[i]<=n; j++) if(DP[i][j]) DP[i][j+b[i]] = 1; } if(!DP[k][n]){ 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 | Incorrect | 1 ms | 212 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 304 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 312 KB | Output is correct |
5 | Correct | 1 ms | 312 KB | Output is correct |
6 | Correct | 1 ms | 304 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 | Incorrect | 1 ms | 212 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 212 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 212 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 212 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |