QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#341379 | #8276. Code Congestion | james1BadCreeper | WA | 0ms | 3700kb | C++14 | 1.4kb | 2024-02-29 18:12:43 | 2024-02-29 18:12:43 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long i64;
const int P = 998244353;
int c, n, T;
int a[205], t[205], p[205];
int f[300005], g[300005];
i64 pr[205];
int main(void) {
ios::sync_with_stdio(0);
cin >> c >> n >> T;
for (int i = 1; i <= n; ++i) cin >> a[i];
for (int i = 1; i <= n; ++i) cin >> t[i];
for (int i = p[0] = 1; i <= n; ++i) p[i] = 2 * p[i - 1] % P;
int ans = 0;
f[0] = 1;
for (int i = 1; i <= n; ++i) {
int sum = 0;
for (int j = 0; j <= T - t[i]; ++j) sum = (sum + f[j]) % P;
ans = (ans + 1ll * a[i] * sum % P * p[n - i]) % P;
// cout << i << " " << sum << " IOI\n";
for (int j = T; j >= t[i]; --j)
f[j] = (f[j] + f[j - t[i]]) % P;
}
// 作为 IOI 赛制时的得分,前 i 个选背包
// 作为 OI 赛制时的得分,后 i 个选背包
for (int i = 1; i <= n; ++i) pr[i] = pr[i - 1] + t[i];
g[0] = 1;
for (int i = n; i >= 1; --i) {
if (pr[i - 1] + t[i] <= T) {
int sum = 0;
for (int j = 0; j <= T - pr[i]; ++j) sum = (sum + g[j]) % P;
// cout << i << " " << sum << " OI\n";
ans = (ans + 1ll * a[i] * sum % P * p[i - 1]) % P;
}
for (int j = T; j >= t[i]; --j) g[j] = (g[j] + g[j - t[i]]) % P;
}
cout << ans << '\n';
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3700kb
input:
3 3 2 3 4 1 2 2
output:
29
result:
wrong answer 1st numbers differ - expected: '40', found: '29'