QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#836332 | #9916. Defeat the Enemies | ucup-team191# | WA | 1197ms | 84324kb | C++23 | 1.9kb | 2024-12-28 18:23:06 | 2024-12-28 18:23:06 |
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 vi=vector<int>;
using vl=vector<ll>;
#define pb push_back
#define all(a) begin(a),end(a)
const int N=30010,MOD=998244353,K=110;
const char en='\n';
const ll LLINF=1ll<<60;
int add(int a,int b)
{
if (a+b>=MOD) return a+b-MOD;
return a+b;
}
pair<ll,int> mer(pair<ll,int> a,pair<ll,int> b)
{
if (a.x==b.x) return {a.x,add(a.y,b.y)};
else return min(a,b);
}
int t,n,m,k;
pair<ll,int> dp[N][2*K];
ll maa[N],su[N],co[K],a[N*20],b[N*20];
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cin>>t;
while (t--)
{
cin>>n>>m;
for (int i=0;i<=2*m+2*K;++i)
{
maa[i]=0;
for (int j=0;j<K;++j) dp[i][j]=pair<ll,int>(LLINF,0);
}
ll maxb=0;
for (int i=0;i<n;++i) cin>>a[i];
for (int i=0;i<n;++i) cin>>b[i];
for (int i=0;i<n;++i)
{
maa[b[i]]=max(maa[b[i]],a[i]);
maxb=max(maxb,b[i]);
}
cin>>k;
for (int i=1;i<=k;++i) cin>>co[i];
ll mas=0;
for (int i=1;i<=2*m+2*k;++i)
{
if (i<=maxb) mas=max(mas,i+maa[i]);
su[i]=mas-i;
}
dp[0][0]={0,1};
pair<ll,int> an={LLINF,0};
for (int i=0;i<=2*m+2*k;++i) for (int j=0;j<2*k;++j) if (dp[i][j].x!=LLINF)
{
//cout<<i<<' '<<j<<' '<<dp[i][j].x<<' '<<dp[i][j].y<<endl;
ll po=j+su[i],re=0;
if (po<=0 && i>=maxb)
{
an=mer(an,dp[i][j]);
//cout<<an.x<<' '<<an.y<<en;
continue;
}
for (int l=1;l<=k;++l) if (i+l<=2*m+2*k)
{
if (maa[i+l]) re=max(re,maa[i+l]);
int cu=max(re,po-l);
//cout<<i<<' '<<j<<' '<<l<<' '<<po<<' '<<cu<<' '<<su[i+l]<<' '<<su[i+l]+k<<endl;
assert(cu>=su[i+l] && cu<=su[i+l]+2*k);
//if (cu>=su[i+l]+k) continue;
cu-=su[i+l];
dp[i+l][cu]=mer(dp[i+l][cu],{dp[i][j].x+co[l],dp[i][j].y});
}
}
cout<<an.x<<' '<<an.y<<en;
}
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 9788kb
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: 0
Accepted
time: 11ms
memory: 9776kb
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 4 1 36 1 12 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 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 6 4 20 1 8 2 10 1 2 1 2 1 50 1 24 1 6 1 10 16 10 1 6 1 3 1 ...
result:
ok 2000 numbers
Test #3:
score: 0
Accepted
time: 24ms
memory: 7660kb
input:
200 50 16 15 15 15 14 15 13 15 15 14 15 16 16 16 12 16 16 16 16 14 13 14 16 13 16 13 16 14 13 16 16 12 14 16 15 13 16 14 16 12 15 14 15 13 14 15 15 15 15 16 13 13 14 16 13 16 16 16 15 13 15 13 16 15 15 16 16 16 16 16 15 16 16 14 12 15 16 16 16 13 12 15 15 16 12 15 14 16 16 16 12 16 16 16 16 15 14 15...
output:
14 6889 68 33856 60 841 388 14400 20 214369 100 1 72 8281 6 256 39 30 4 1 58 1 12 144 4 144 116 169 46 38416 100 1 26 11025 88 36 80 1 10 81 114 100 92 413318192 56 1 50 1296 400 481524050 68 1 32 9 6 1 1100 1 100 103437186 46 1600 80 57 44 576 92 1 26 441 7 320 106 9 68 29241 34 324 29 7878 4 1 4 1...
result:
ok 400 numbers
Test #4:
score: 0
Accepted
time: 112ms
memory: 84324kb
input:
1 500000 10000 3544 1546 5208 6621 759 9303 9198 8910 9046 2355 5960 2034 7059 8504 4449 9573 3020 7106 6973 2021 5158 6148 386 3559 5050 9264 9497 2912 1170 7698 4529 4172 7729 3382 7613 3770 6552 2365 2193 9581 146 7853 5384 4589 3369 3102 9585 3124 1886 8301 8125 3842 4101 5388 3571 10 7190 2464 ...
output:
22388256114 1
result:
ok 2 number(s): "22388256114 1"
Test #5:
score: -100
Wrong Answer
time: 1197ms
memory: 36644kb
input:
5 41415 228 216 219 186 142 203 168 225 177 190 214 171 210 212 220 216 215 209 224 226 207 172 218 190 227 194 221 178 207 220 188 226 227 226 225 197 181 201 223 205 209 183 212 223 182 228 198 222 181 206 148 177 221 226 226 226 196 216 209 207 214 220 156 201 212 224 228 155 212 179 226 215 166 ...
output:
0 0 0 0 0 0 0 0 0 0
result:
wrong answer 1st numbers differ - expected: '5914951720', found: '0'