QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#835508 | #9916. Defeat the Enemies | ucup-team5075# | WA | 7ms | 72608kb | C++14 | 1.4kb | 2024-12-28 12:26:49 | 2024-12-28 12:26:49 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N=5e5+9,M=20009,mod=998244353;
const ll inf=1e16;
int n,m,a[N],b[N];
int K,c[N];
struct Info{
ll ans;int cnt;
Info(ll x=inf,int y=0){ans=x,cnt=y;}
};
Info operator+ (Info x,Info y)
{
Info ans;
ans.ans=min(x.ans,y.ans);
ans.cnt=0;
if(ans.ans==x.ans) ans.cnt=x.cnt;
if(ans.ans==y.ans) (ans.cnt+=y.cnt)%=mod;
return ans;
}
Info operator+ (Info x,int y){x.ans+=y;return x;}
Info dp[M][200];
vector<int> vec[M];
void work()
{
scanf("%d%d",&n,&m);
for(int i=1;i<=n;i++) scanf("%d",&a[i]);
for(int i=1;i<=n;i++) scanf("%d",&b[i]);
int mx=0,mxa=0;
for(int i=1;i<=m;i++) mx=max(mx,a[i]+b[i]),mxa=max(mxa,a[i]);
for(int i=1;i<=n;i++) vec[a[i]].push_back(i);
scanf("%d",&K);
for(int i=1;i<=K;i++) scanf("%d",&c[i]);
for(int j=0;j<=mx+K+K;j++) for(int i=0;i<=K;i++) dp[j][i]=Info();
dp[0][0]=Info(0,1);
Info ans=Info();
for(int i=0;i<=mx+K+K;i++)
for(int j=0;j<=K;j++)
if(dp[i][j].ans!=inf)
{
// cerr<<i<<" "<<j<<" "<<dp[i][j].ans<<endl;
if(i>=mx+j) {ans=ans+dp[i][j];continue;}
for(int k=1;k<=K;k++)
{
int tmp=j;
for(int l=i+1;l<=i+k;l++)
for(int p:vec[l]) tmp=max(tmp,i+k+b[p]-mx);
dp[i+k][tmp]=dp[i+k][tmp]+(dp[i][j]+c[k]);
}
}
printf("%lld %d\n",ans.ans,ans.cnt);
for(int i=1;i<=mxa;i++) vec[i].clear();
}
signed main()
{
int T;
scanf("%d",&T);
while(T--) work();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 72608kb
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: 7ms
memory: 70940kb
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 2 1 15 4 8 4 14 1 8 4 36 1 14 1 27 1 2 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 10 1 40 1 12 15 8 1 30 1 5 1 4 1 3 1 35 1 10 1 2 1 8 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 6 4 20 1 8 1 10 1 2 1 2 1 50 1 24 1 6 1 10 16 10 1 6 1 3...
result:
wrong answer 19th numbers differ - expected: '4', found: '8'