QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#863158 | #9679. 盒子 | APPAwang | 0 | 1ms | 4096kb | C++14 | 1.1kb | 2025-01-19 13:52:44 | 2025-01-19 13:52:52 |
answer
#include<bits/stdc++.h>
using namespace std;
char buf[1<<20],*p1,*p2;
#define gc() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<20,stdin),p1==p2)?0:*p1++)
int read(){int x=0;bool neg=0;char ch=gc();
while(ch<'0'||ch>'9')neg|=(ch=='-'),ch=gc();
while(ch>='0'&&ch<='9')x=(x<<1)+(x<<3)+(ch^48),ch=gc();
return neg?-x:x;
}//快读
#define ll long long
int n,m,k,c;
#define upper 50000
int dp[upper+5],s[100005];
int main(){
int T=read(),i,j;
while(T--){
n=read();m=read();k=read();c=read();
for(i=1;i<=n;i++)s[i]=s[i-1]+read();
for(i=s[m]-1;i>=0;i--)
dp[i]=min(dp[i+1]+1,dp[i+k]+c);
for(i=k-1;i>=0;i--)
dp[0]=min(dp[0],dp[i]+c);
for(i=m+1;i<=n;i++){
int p=s[i-1]-s[i-m];
for(j=p+1;j<=upper;j++)
dp[j]=dp[p];
p=s[i]-s[i-1];
for(j=upper;j>=p;j--)
dp[j]=dp[j-p];
for(j=p-1;j>=0;j--)
dp[j]=min(dp[j+1]+1,dp[j+k]+c);
for(j=k-1;j>=0;j--)
dp[0]=min(dp[0],dp[j]+c);
}
printf("%d\n",dp[0]);
}
return 0;
}
详细
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 4096kb
input:
3 5 2 4 3 2 2 1 2 2 4 2 4 3 2 4 1 1 10 3 5 1 2 2 2 2 1 1 1 10 2 2
output:
7 11 15
result:
wrong answer 2nd numbers differ - expected: '7', found: '11'
Subtask #2:
score: 0
Skipped
Dependency #1:
0%
Subtask #3:
score: 0
Skipped
Dependency #2:
0%
Subtask #4:
score: 0
Runtime Error
Test #35:
score: 0
Runtime Error
input:
66664 7 2 82188055 1 35930054 4923258 36288509 46890418 53350617 49812938 68015568 10 2 460335201 1 305598063 240803174 36008172 416771728 391050572 270293987 333994588 436573185 216917970 103343453 9 3 119910901 1 35106715 29444257 72409421 49339248 23617992 3266647 38704192 75874356 72979434 10 1 ...
output:
result:
Subtask #5:
score: 0
Skipped
Dependency #1:
0%