QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#337097 | #8276. Code Congestion | ucup-team2000# | WA | 38ms | 67284kb | C++20 | 2.9kb | 2024-02-25 03:44:28 | 2024-02-25 03:44:29 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pi pair<int,int>
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define lep(i,a,b) for(int i = (a); i <= (b); i++)
#define rep(i,a,b) for(int i = (a); i >= (b); i--)
const int mod = 998244535;
const int maxn = 205;
const int maxS = 3e5 + 5;
int F[maxn][maxS], G[maxn][maxS];
int prod(int a, int b) {
return (a * b) % mod;
}
int add(int a, int b) {
return (a + b) % mod;
}
void solve() {
int n, T;
cin >> n >> T;
vector<int> powers(n+1);
powers[0] = 1;
lep(i,1,n) {
powers[i] = prod(powers[i-1],2);
}
vector<int> a(n+1), t(n+1),pre(n+1);
lep(i,1,n) {
cin >> a[i];
}
lep(i,1,n) {
cin >> t[i];
pre[i] = t[i] + pre[i-1];
}
F[0][0] = 1;
lep(i,1,n) {
lep(j,0,maxS-1) {
F[i][j] = add(F[i][j],F[i-1][j]);
int j2 = min(maxS-1,j+t[i]);
F[i][j2] = add(F[i][j2],F[i-1][j]);
}
}
G[n+1][0] = 1;
rep(i,n,1) {
// cout << "i: "
// if (i == n) {
// cout << "hi0\n";
// }
lep(j,0,maxS-1) {
G[i][j] = add(G[i][j],G[i+1][j]);
// if (i == n and j == 0) {
// cout << "hi\n";
// }
int j2 = min(maxS-1,j+t[i]);
G[i][j2] = add(G[i][j2],G[i+1][j]);
}
}
int ans = 0;
lep(i,1,n) {
// cout << "i: " << i << "\n";
// case 1: i is visible
int sm = 0;
lep(j,0,T-t[i]) {
sm = add(sm, F[i-1][j]);
}
int num_ways = prod(sm, powers[n-i]);
// cout << "c1 num_ways: " << num_ways << "\n";
ans = add(ans, prod(a[i], num_ways));
// case 2: i is invisible
sm = 0;
lep(j,max(0LL,T-pre[i]+1),maxS-1) {
sm = add(sm, G[i+1][j]);
}
int compll = add(prod(powers[i-1], sm),powers[n-1]);
num_ways = add(powers[n],-compll);
// cout << "c2 num_ways: " << num_ways << "\n";
// cout << "sum: " << sm << "\n";
// cout << "\n\n";
if (num_ways < 0) num_ways += mod;
ans = add(ans, prod(a[i], num_ways));
}
// cout << "G2:\n";
// lep(i,0,5) {
// cout << G[2][i] << " ";
// }
// cout << "\n";
// cout << "G3:\n";
// lep(i,0,5) {
// cout << G[3][i] << " ";
// }
// cout << "\n";
// cout << "G4:\n";
// lep(i,0,5) {
// cout << G[4][i] << " ";
// }
// cout << "\n";
cout << ans << "\n";
}
signed main() {
ios::sync_with_stdio(0);
cin.tie(0);
solve();
return 0;
}
// i: 1
// c1 num_ways: 4
// c2 num_ways: 8
// sum: 0
// i: 2
// c1 num_ways: 2
// c2 num_ways: 8
// sum: 0
// i: 3
// c1 num_ways: 0
// c2 num_ways: 4
// sum: 1
// 70
详细
Test #1:
score: 100
Accepted
time: 11ms
memory: 20604kb
input:
3 3 2 3 4 1 2 2
output:
40
result:
ok 1 number(s): "40"
Test #2:
score: -100
Wrong Answer
time: 38ms
memory: 67284kb
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:
745633483
result:
wrong answer 1st numbers differ - expected: '745634757', found: '745633483'