QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#835464 | #9916. Defeat the Enemies | ucup-team1004# | WA | 2ms | 10044kb | C++14 | 1.3kb | 2024-12-28 11:58:41 | 2024-12-28 11:58:43 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=3e4+10,K=110,mod=998244353;
struct node{
ll val;
int cnt;
node add(int x){return node{val+x,cnt};}
}f[N][K];
void operator +=(node &a,node b)
{
if(a.cnt==0||a.val>b.val) return a=b,void();
else if(b.cnt==0||a.val<b.val) return;
a.cnt+=b.cnt;
if(a.cnt>mod) a.cnt-=mod;
}
int T,n,m,k,t[N],h[N][K],c[K],a[N*100],b[N*100];
int main()
{
scanf("%d",&T);
for(int i=1;i<N;i++) t[i]=-1e9;
while(T--)
{
scanf("%d%d",&n,&m),m=0;
for(int i=1;i<=n;i++) scanf("%d",&a[i]);
for(int i=1;i<=n;i++) scanf("%d",&b[i]);
for(int i=1;i<=n;i++)
{
t[b[i]]=max(t[b[i]],a[i]);
m=max(m,a[i]+b[i]);
}
scanf("%d",&k);
for(int i=1;i<=k;i++) scanf("%d",&c[i]);
for(int i=0;i<=m+2*k;i++)
for(int j=0;j<=k;j++) f[i][j]=node{0,0};
for(int i=0;i<=m+k;i++)
{
for(int j=1;j<=k;j++)
h[i][j]=max(t[i+j]+i,h[i][j-1]);
for(int j=1;j<=k;j++)
h[i][j]=max(0,h[i][j]+j-m);
}
f[0][0]=node{0,1};
for(int i=0;i<=m+k;i++)
for(int x=0;x<=k;x++)
for(int y=1;y<=k;y++)
f[i+y][max(x,h[i][y])]+=f[i][x].add(c[y]);
node ans=node{0,0};
for(int i=0;i<=2*k;i++)
for(int j=0;j<=min(i,k);j++) ans+=f[i+m][j];
printf("%lld %d\n",ans.val,ans.cnt%mod);
for(int i=1;i<=m;i++) t[i]=-1e9;
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 10044kb
input:
4 5 5 3 5 2 1 2 3 1 3 2 3 3 2 3 4 3 2 2 2 2 2 2 2 3 2 3 3 7 6 5 3 4 6 6 3 4 4 6 4 2 3 5 5 4 2 4 6 7 10 100 38 49 79 66 49 89 21 55 13 23 67 56 26 39 56 16 84 50 92 82 11 6 6 7 8 9 9 9 9 9 9 9
output:
9 1 6 4 18 18 99 44387
result:
ok 8 numbers
Test #2:
score: -100
Wrong Answer
time: 2ms
memory: 9968kb
input:
1000 5 3 1 1 3 1 2 3 2 1 1 2 1 5 5 3 3 3 2 2 1 1 1 3 1 1 3 3 1 3 5 5 4 3 5 1 4 5 5 2 5 5 2 1 5 5 5 5 5 5 5 4 2 1 2 4 1 2 1 1 5 3 2 1 2 1 1 1 3 2 1 1 1 5 2 1 1 1 1 1 3 2 2 1 5 5 2 3 5 2 2 5 2 4 3 1 2 3 3 5 1 1 1 1 1 1 1 1 1 1 1 3 5 4 4 5 4 1 4 4 4 2 4 3 1 3 3 1 2 1 5 2 2 3 4 2 4 1 5 4 5 1 4 2 5 1 5 1...
output:
20 1 3 1 9 1 5 4 20 1 4 2 15 4 12 2 14 1 4 1 36 1 12 1 27 1 9 1 20 1 4 1 10 1 23 1 10 1 4 1 28 1 4 1 5 1 4 1 6 1 8 1 6 1 16 1 9 6 5 1 30 1 4 1 4 1 2 1 35 1 10 1 2 1 4 1 15 6 4 1 20 1 4 1 6 1 40 1 4 1 18 1 8 1 7 1 6 1 2 1 10 1 3 1 9 1 8 1 4 1 10 2 20 1 8 2 10 1 5 2 2 1 50 1 24 1 6 1 10 16 10 1 6 1 3 ...
result:
wrong answer 11th numbers differ - expected: '2', found: '4'