QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#847277 | #9916. Defeat the Enemies | eastcloud | WA | 2ms | 9884kb | C++23 | 2.4kb | 2025-01-07 19:43:22 | 2025-01-07 19:43:23 |
Judging History
answer
#include<bits/stdc++.h>
#define ll long long
#define pi pair<ll,ll>
#define vi vector<ll>
#define cpy(x,y,s) memcpy(x,y,sizeof(x[0])*(s))
#define mset(x,v,s) memset(x,v,sizeof(x[0])*(s))
#define all(x) begin(x),end(x)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ary array
#define eb emplace_back
#define IL inline
#define For(i,j,k) for(ll i=(j);i<=(k);i++)
#define Fol(i,k,j) for(ll i=(k);i>=(j);i--)
using namespace std;
#define inf 0x3f3f3f3f3f3f3f3f
#define N 500005
#define M 13005
#define K 105
#define mod 998244353
ll read(){
ll x=0,f=1;char ch=getchar();
while(ch<'0' || ch>'9')f=(ch=='-'?-1:f),ch=getchar();
while(ch>='0' && ch<='9')x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
return x*f;
}
void write(ll x){
if(x<0)x=-x,putchar('-');
if(x/10)write(x/10);
putchar(x%10+'0');
}
void debug(auto &&...x){
((cerr<<x<<' '),...);
cerr<<'\n';
}
IL ll pls(ll x,ll y){return (x+y>=mod?x+y-mod:x+y);}
IL ll sub(ll x,ll y){return (x-y<0?x-y+mod:x-y);}
IL void Add(ll &x,ll y){x=pls(x,y);}
IL void Dec(ll &x,ll y){x=sub(x,y);}
IL ll mul(ll x,ll y){return x*1ll*y%mod;}
ll a[N],b[N],f[M][K],g[M][K],C[M];
ll c[K];
void solve(){
ll n=read(),m=read(),maxn=0;
For(i,1,n)a[i]=read();
For(i,1,n)b[i]=read(),maxn=max(maxn,a[i]+b[i]),C[b[i]]=max(C[b[i]],a[i]);
ll k=read();
For(i,1,k)c[i]=read();
For(i,0,m+2*k)For(j,0,k)f[i][j]=inf,g[i][j]=0;
f[0][0]=0;g[0][0]=1;
ll res=inf,coef=0;
//debug(maxn);
For(i,0,m+2*k)For(j,0,k){
if(!g[i][j])continue;
ll flag=0,ext=0;
//debug(i,j,f[i][j],g[i][j]);
For(l,1,k){
if(C[l+i])ext=max(ext,C[l+i]+(l+i)),flag=1;
ll val=(ext>maxn?ext-maxn:0);
if(f[l+i][max(val,j)]==f[i][j]+c[l])Add(g[l+i][max(val,j)],g[i][j]);
else if(f[l+i][max(val,j)]>f[i][j]+c[l])g[l+i][max(val,j)]=g[i][j],f[l+i][max(val,j)]=f[i][j]+c[l];
if(flag)ext++;
}
if(i>=maxn && i-maxn>=j){
//debug(i,j,f[i][j]);
if(f[i][j]==res)Add(coef,g[i][j]);
else if(f[i][j]<res)res=f[i][j],coef=g[i][j];
}
}
write(res);putchar(' ');write(coef);putchar('\n');
For(i,1,n)C[b[i]]=0;
}
int main(){
#ifdef EAST_CLOUD
freopen("a.in","r",stdin);
//freopen("a.out","w",stdout);
#endif
ll T=read();while(T--)solve();
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 9884kb
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: 9732kb
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 3 20 1 2 1 15 3 8 4 4557430888798830399 0 4 1 4557430888798830399 0 12 1 4557430888798830399 0 2 1 20 1 4 1 10 1 23 1 10 1 4 1 28 1 4 1 9 5 4 1 6 1 9 4 6 1 16 1 9 6 5 1 4557430888798830399 0 4 1 4 1 2 1 4557430888798830399 0 11 5 2 1 4 1 15 6 4 1 20 1 4 1 6 1 4557430888798830399 0 4 1...
result:
wrong answer 8th numbers differ - expected: '4', found: '3'