QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#345482 | #8276. Code Congestion | ucup-team191# | WA | 2ms | 36388kb | C++23 | 1.5kb | 2024-03-07 00:16:53 | 2024-03-07 00:16:54 |
Judging History
answer
#include <bits/stdc++.h>
#define x first
#define y second
using namespace std;
using ll=long long;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using vi=vector<int>;
using vl=vector<ll>;
#define pb push_back
#define all(a) begin(a),end(a)
const int N=210,M=300010,MOD=998244353;
const char en='\n';
const ll LLINF=1ll<<60;
void ad(int&a,int b)
{
a+=b;
if (a>=MOD) a-=MOD;
}
int add(int a,int b)
{
if (a+b>=MOD) return a+b-MOD;
return a+b;
}
void su(int&a,int b)
{
a-=b;
if (a<0) a+=MOD;
}
int sub(int a,int b)
{
if (a<b) return a-b+MOD;
return a-b;
}
int mul(int a,int b)
{
return a*1ll*b%MOD;
}
int n,t,dp1[N][M],dp2[N][M],a[N],ti[N],p2[N];
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cin>>n>>t;
p2[0]=1;
for (int i=1;i<=n;++i) p2[i]=mul(p2[i-1],2);
for (int i=0;i<n;++i) cin>>a[i];
for (int i=0;i<n;++i) cin>>ti[i];
dp1[0][0]=1;
for (int i=0;i<n;++i)
{
for (int j=0;j<=t;++j) dp1[i+1][j]=dp1[i][j];
for (int j=t-ti[i];j>=0;--j) ad(dp1[i+1][j+ti[i]],dp1[i][j]);
}
dp2[n][0]=1;
for (int i=n-1;i>=0;--i)
{
for (int j=0;j<=t;++j) dp2[i][j]=dp2[i+1][j];
for (int j=0;j<=t-ti[i];++j) ad(dp2[i][j+ti[i]],dp2[i+1][j]);
}
int an=0;
ll ps=0;
for (int i=0;i<n;++i)
{
int nacm=0;
for (int j=0;j<=t-ti[i];++j) ad(nacm,dp1[i][j]);
int ninv=mul(p2[n-i-1],nacm),nvis=0;
ps+=ti[i];
if (ps<=t)
{
int naci=0;
for (int j=0;j<=t-ti[i];++j) ad(naci,dp2[i+1][j]);
nvis=mul(p2[i],naci);
}
ad(an,mul(add(nvis,ninv),a[i]));
}
cout<<an<<en;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 2ms
memory: 11940kb
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: 36388kb
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:
648329359
result:
wrong answer 1st numbers differ - expected: '745634757', found: '648329359'