QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#859933 | #9679. 盒子 | phelixzhen_false | 0 | 43ms | 5864kb | C++20 | 2.3kb | 2025-01-18 08:38:07 | 2025-01-18 08:38:19 |
Judging History
answer
#include<bits/stdc++.h>
bool Mbg;
using namespace std;
#define vec vector
#define pb push_back
#define eb emplace_back
#define siz(vec) ((int)(vec).size())
#define all(vec) (vec).begin(),(vec).end()
template<class T>
void operator +=(vec<T> &a,T b){a.push_back(b);}
template<class T>
void operator --(vec<T> &a){a.pop_back();}
#define pii pair<int,int>
#define x first
#define y second
#define mp make_pair
#define exc(exp) if(exp)continue;
#define stop(exp) if(exp)break;
#define ret(exp) if(exp)return;
#define deb(var) cerr<<#var<<'='<<(var)<<"; "
#define debl(var) cerr<<#var<<'='<<(var)<<";\n"
#define ins insert
#define era erase
#define lb lower_bound
#define ub upper_bound
#define int long long
#define inf (long long)(1e18)
template<class T>
bool Min(T &x,T y){return x>y?x=y,1:0;}
template<class T>
bool Max(T &x,T y){return x<y?x=y,1:0;}
const int mod=998244353;
void Add(int &x,int y){x=x+y<mod?x+y:x+y-mod;}
void Dec(int &x,int y){x=x>=y?x-y:x-y+mod;}
int fpm(int x,int y){
int ans=1;for(;y;y>>=1,x=1ll*x*x%mod)if(y&1)ans=1ll*x*ans%mod;return ans;
}
int n,m,k,c,a[500010],s[500010],f[500010];
void work(){
cin>>n>>m>>k>>c;
for(int i=1;i<=n;i++){
cin>>a[i];
s[i]=s[i-1]+a[i];
}
f[n+1]=0;
for(int i=n;i;i--){
f[i]=f[i+1]+a[i];
int lst=0,rem=0;
for(int j=i;j<=n;j++){
// [i,j] clearable
if(a[j]+rem<k){
if(!rem)lst=j;
rem+=a[j];
}else{
int r=a[j]-(k-rem);
if(j-lst+1>m){
break;
}
rem=r%k;lst=j;
}
if(rem&&j-lst+1>m){
break;
}
Min(f[i],f[j+1]+(s[j]-s[i-1]+k-1)/k*c);
Min(f[i],f[j+1]+(s[j]-s[i-1])/k*c+(s[j]-s[i-1])%k);
}
}
cout<<f[1]<<'\n';
}
bool Med;
signed main(){
ios::sync_with_stdio(0),
cin.tie(0),cout.tie(0);
int T=1;cin>>T;while(T--)work();
// cerr<<"Time: "<<clock()<<" ms;\n";
// cerr<<"Memory: "<<abs(&Med-&Mbg)/1024.0/1024.0<<" MiB.\n";
}
/*
- CONTINUE, NON-STOPPING, FOR THE FAITH
- START TYPING IF YOU DON'T KNOW WHAT TO DO
- STOP TYPING IF YOU DON'T KNOW WHAT YOU'RE DOING
*/
詳細信息
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 17
Accepted
time: 0ms
memory: 5860kb
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 7 6
result:
ok 3 number(s): "7 7 6"
Test #2:
score: 0
Wrong Answer
time: 0ms
memory: 5860kb
input:
65 7 1 27 22 70 29 32 15 69 79 84 10 2 2 1 76 63 99 67 75 30 29 45 79 23 9 1 4 3 47 91 10 30 91 29 12 14 53 10 1 5 4 92 22 92 27 30 50 59 6 57 58 5 2 15 15 59 27 70 24 11 5 2 42 42 70 50 42 55 5 6 2 54 46 67 14 52 80 95 3 10 2 89 88 55 14 45 14 90 81 38 40 54 17 5 2 93 86 35 58 76 64 73 6 1 45 43 63...
output:
378 293 377 493 191 222 271 445 285 352 307 270 348 312 370 427 394 185 318 502 344 304 330 345 262 220 454 243 160 369 482 580 330 444 202 293 288 590 280 487 253 494 523 532 204 259 368 323 368 392 516 494 198 209 292 273 297 258 525 557 216 448 433 430 595
result:
wrong answer 1st numbers differ - expected: '320', found: '378'
Subtask #2:
score: 0
Skipped
Dependency #1:
0%
Subtask #3:
score: 0
Skipped
Dependency #2:
0%
Subtask #4:
score: 0
Wrong Answer
Test #35:
score: 0
Wrong Answer
time: 43ms
memory: 5864kb
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:
5 8 4 1120865848 994384252 3 1378399985 1687097207 3 4 408514679 473544235 1276878548 5 53602490 2296531289 786405577 832195938 5 7 5 2501148100 311976114 4 3 2090604 7 4 254592698 5 6 4 5 347826348 5 601619031 3 5 557200376 497394132 6 6 1481528800 996142069 4 1400555852 2922977667 1071146725 7 5 7...
result:
wrong answer 4th numbers differ - expected: '13', found: '1120865848'
Subtask #5:
score: 0
Skipped
Dependency #1:
0%