QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#863161#9679. 盒子APPAwang17 15ms4096kbC++141.2kb2025-01-19 13:54:572025-01-19 13:54:58

Judging History

你现在查看的是最新测评结果

  • [2025-01-19 13:54:58]
  • 评测
  • 测评结果:17
  • 用时:15ms
  • 内存:4096kb
  • [2025-01-19 13:54:57]
  • 提交

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();
        memset(dp,0,sizeof(dp));
        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;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 17
Accepted

Test #1:

score: 17
Accepted
time: 1ms
memory: 3840kb

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: 17
Accepted
time: 12ms
memory: 4096kb

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:

320
293
287
398
191
222
271
445
285
344
307
270
348
312
370
427
199
184
318
502
344
197
330
233
262
220
454
243
160
280
482
580
330
373
202
293
228
590
268
475
253
494
523
476
186
223
368
323
368
392
507
494
132
209
224
250
297
216
525
557
172
448
433
430
578

result:

ok 65 numbers

Test #3:

score: 17
Accepted
time: 14ms
memory: 3968kb

input:

6
72 4 97 91
33 34 16 21 70 62 12 30 49 27 64 63 82 53 69 14 50 52 59 19 72 79 26 86 55 50 41 85 18 8 97 51 30 7 29 43 12 10 19 13 50 60 57 23 23 11 77 23 58 35 17 47 37 21 47 65 66 49 80 51 67 39 62 80 100 59 12 17 15 71 86 97
59 4 101 92
89 100 35 32 57 26 43 81 44 36 78 47 54 28 96 80 55 82 9 95 ...

output:

3114
3115
2543
4767
3371
5050

result:

ok 6 numbers

Test #4:

score: 17
Accepted
time: 15ms
memory: 3968kb

input:

5
100 2 52 49
90 44 90 2 13 5 21 25 6 10 45 70 3 15 46 46 65 22 28 36 68 50 60 92 3 77 56 98 26 41 42 56 29 31 70 59 45 28 16 46 55 76 79 82 31 26 23 90 39 72 94 3 98 15 68 33 91 81 85 40 38 43 10 42 66 79 56 72 37 3 23 32 41 57 47 75 27 61 30 21 46 66 87 67 59 88 29 82 28 38 46 8 21 77 21 7 52 85 9...

output:

4458
5051
4722
4797
4419

result:

ok 5 number(s): "4458 5051 4722 4797 4419"

Subtask #2:

score: 0
Runtime Error

Dependency #1:

100%
Accepted

Test #5:

score: 0
Runtime Error

input:

65
7 1 266582645 266569542
368884862 154420474 168221985 75773522 366018465 417636088 444993440
10 2 375072157 375064876
370894262 247786067 280616106 111957276 105186734 167332630 296036702 83312734 27516860 167992391
9 2 454297753 454278488
133388246 410399039 130735692 54284254 59071687 238415181...

output:


result:


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:

100%
Accepted

Dependency #2:

0%