QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#352267 | #8276. Code Congestion | berarchegas# | WA | 1ms | 7940kb | C++20 | 1.9kb | 2024-03-13 06:15:00 | 2024-03-13 06:15:00 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
mt19937 rng((int) chrono::steady_clock::now().time_since_epoch().count());
const int MOD = 1e9 + 7;
const int MAXN = 2e2 + 5;
const int MAXT = 3e5 + 10;
const ll INF = 2e18;
int a[MAXN], t[MAXN];
int dp[MAXN][MAXT], sp[MAXN][MAXT];
ll pot[MAXN];
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
pot[0] = 1;
for(int i = 1; i < MAXN; i++) {
pot[i] = pot[i - 1] * 2;
pot[i] %= MOD;
}
int n, tot;
cin >> n >> tot;
ll resp = 0;
dp[0][0] = 1;
for(int i = 1; i <= n; i++) {
cin >> a[i];
}
for(int i = 1; i <= n; i++) {
cin >> t[i];
for(int j = 0; j + t[i] <= tot; j++) {
dp[i][j + t[i]] += dp[i - 1][j];
dp[i][j + t[i]] %= MOD;
resp += (dp[i - 1][j] * a[i]) % MOD * pot[n - i];
resp %= MOD;
}
for(int j = 0; j <= tot; j++) {
dp[i][j] += dp[i - 1][j];
dp[i][j] %= MOD;
}
}
for(int i = 0; i <= n; i++) {
for(int j = 0; j <= tot; j++) {
dp[i][j] = 0;
}
}
dp[n + 1][0] = 1;
for(int i = n; i >= 1; i--) {
for(int j = 0; j + t[i] <= tot; j++) {
dp[i][j + t[i]] += dp[i + 1][j];
dp[i][j + t[i]] %= MOD;
}
for(int j = 0; j <= tot; j++) {
dp[i][j] += dp[i + 1][j];
dp[i][j] %= MOD;
}
}
int sp = 0;
for(int i = 1; i <= n; i++) {
sp += t[i];
ll mn = 0;
for(int j = 0; j + sp <= tot; j++) {
mn += dp[i + 1][j];
mn %= MOD;
}
resp += (mn * a[i]) % MOD * pot[i - 1];
resp %= MOD;
}
cout << resp << '\n';
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 7820kb
input:
3 3 2 3 4 1 2 2
output:
40
result:
ok 1 number(s): "40"
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 7940kb
input:
13 96 56231 258305 150103 164646 232643 37457 239584 192517 167805 215281 159832 98020 141006 54 1 38 1 4 1 4 11 1 4 8 22 1
output:
733345179
result:
wrong answer 1st numbers differ - expected: '745634757', found: '733345179'