# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
796338 |
2023-07-28T09:57:25 Z |
Johann |
Cookies (JOI23_cookies) |
C++14 |
|
1 ms |
212 KB |
#include "bits/stdc++.h"
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
int N, M;
vpii A;
vi B;
vi dp;
vi used;
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cin >> N;
A.resize(N);
for (int i = 0; i < N; ++i)
cin >> A[i].first, A[i].second = i;
cin >> M;
B.resize(M);
for (int i = 0; i < M; ++i)
cin >> B[i];
// sort(all(A));
dp.assign(N + 1, INT_MAX), used.resize(N + 1);
dp[0] = 0;
for (int i = 1; i < sz(dp); ++i)
for (int b = sz(B) - 1; b >= 0; --b)
if (i - B[b] >= 0 && dp[i] > dp[i - B[b]] + 1)
dp[i] = dp[i - B[b]] + 1, used[i] = b;
int i = N;
cout << dp[i] << "\n";
while (i > 0)
{
int b = used[i];
cout << B[b];
for (int j = 0; j < B[b]; ++j)
cout << " " << i--;
cout << "\n";
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 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 |
Incorrect |
0 ms |
212 KB |
Integer -2147483648 violates the range [-1, 4] |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Integer -2147483648 violates the range [-1, 15] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
Integer -2147483648 violates the range [-1, 15] |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 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 |
Incorrect |
0 ms |
212 KB |
Integer -2147483648 violates the range [-1, 4] |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 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 |
Incorrect |
0 ms |
212 KB |
Integer -2147483648 violates the range [-1, 4] |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 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 |
Incorrect |
0 ms |
212 KB |
Integer -2147483648 violates the range [-1, 4] |
7 |
Halted |
0 ms |
0 KB |
- |