QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#202941 | #2482. Storage Problems | salvator_noster# | WA | 1ms | 5748kb | C++14 | 1.5kb | 2023-10-06 14:14:59 | 2023-10-06 14:15:00 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int SIZE = 400 + 5;
const ll MOD = 167772161;
int n, m;
int wi[SIZE];
ll dp[SIZE][SIZE], tmp[SIZE][SIZE];
void add(ll &a, ll b) {
a = (a + b) % MOD;
return;
}
int main(void) {
scanf("%d%d", &n, &m);
for (int i = 1; i <= n; ++i) {
scanf("%d", &wi[i]);
}
dp[0][0] = 1;
for (int i = 1; i <= n; ++i) {
for (int j = i - 1; j >= 0; --j) {
for (int k = 0; k <= m - wi[i]; ++k) {
add(dp[j + 1][k + wi[i]], dp[j][k]);
}
}
}
for (int i = 0; i <= n; ++i) {
for (int j = 0; j <= m; ++j) {
printf("%lld%c", dp[i][j], " \n"[j == m]);
}
}
for (int i = 1; i <= n; ++i) {
for (int j = 0; j <= n; ++j) {
memcpy(tmp[j], dp[j], (m + 1) * sizeof dp[j][0]);
}
for (int j = 1; j <= n; ++j) {
for (int k = wi[i]; k <= m; ++k) {
add(tmp[j][k], MOD - tmp[j - 1][k - wi[i]]);
}
}
// for (int i = 0; i <= n; ++i) {
// for (int j = 0; j <= m; ++j) {
// printf("%lld%c", tmp[i][j], " \n"[j == m]);
// }
// }
for (int j = 1; j <= n - 1; ++j) {
ll ans = 0;
for (int k = m - wi[i] + 1; k <= m; ++k) {
add(ans, tmp[j][k]);
}
printf("%lld%c", ans, " \n"[j == n - 1]);
}
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 5748kb
input:
3 2 1 1 2
output:
1 0 0 0 2 1 0 0 1 0 0 0 1 0 1 0 2 1
result:
wrong answer 1st lines differ - expected: '1 0', found: '1 0 0'