QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#859733#9679. 盒子lgvc28 987ms26624kbC++231.8kb2025-01-17 22:24:362025-01-17 22:24:38

Judging History

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

  • [2025-01-17 22:24:38]
  • 评测
  • 测评结果:28
  • 用时:987ms
  • 内存:26624kb
  • [2025-01-17 22:24:36]
  • 提交

answer

#include <bits/stdc++.h>
#define int __int128
static char buf[1000000],*paa=buf,*pd=buf;
static char buf2[1000000],*pp=buf2;
#define getchar() paa==pd&&(pd=(paa=buf)+fread(buf,1,1000000,stdin),paa==pd)?EOF:*paa++
inline void pc(char ch){
    if(pp-buf2==1000000) fwrite(buf2,1,1000000,stdout),pp=buf2;
    *pp++=ch;
}
inline void pcc(){
    fwrite(buf2,1,pp-buf2,stdout);
    pp=buf2;
}
inline int read(void){
    int w=1;
    register int x(0);register char c(getchar());
    while(c<'0'||c>'9'){if(c=='-') w=-1;c=getchar();}
    while(c>='0'&&c<='9')x=(x<<1)+(x<<3)+(c^48),c=getchar();
    return w*x;
}
void write(int x){
    static int sta[20];
    int top=0;
    do{
        sta[top++]=x%10,x/=10;
    }while(x);
    while(top) pc(sta[--top]+48);
}
void we(int x){
    write(x);
    pc('\n');
}
int T,N,M,K,C,a[1000009];
int dp[1000009];
inline int fx(int x) {
    return (x%K)*(K-C);
}
signed main(void) {
    T=read();
    int inf=1;
    for(int i=1;i<=36;i++) inf*=10;
    while(T--) {
        N=read();M=read();K=read();C=read();
        int ans=0;
        for(int i=1;i<=N;i++) {
            a[i]=read();
            ans+=a[i];
        }
        dp[N+1]=0;
        for(int i=N;i>=1;i--) {
            dp[i]=inf;
            int su=0;
            int id=i-1;
            for(int j=0;;j++) {
                int la=id;
                while(id<N&&su+a[id+1]<=j*K&&id<la+M) id++,su+=a[id];
                if(id-la>=M) {
                    dp[i]=std::min(dp[i],dp[la+M+1]+j*C*K-su*C);
                    break;
                }
                if(id==N) {
                    dp[i]=std::min(dp[i],j*C*K-su*C);
                    break;
                }
                dp[i]=std::min(dp[i],dp[id+2]+fx(a[id+1]-(j*K-su)));
            }
        }
        printf("%lld\n",(long long)(dp[1]+ans*C)/K);
    }
}

详细

Subtask #1:

score: 17
Accepted

Test #1:

score: 17
Accepted
time: 0ms
memory: 8012kb

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: 1ms
memory: 8008kb

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: 0ms
memory: 7844kb

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: 0ms
memory: 8016kb

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
Wrong Answer

Dependency #1:

100%
Accepted

Test #5:

score: 21
Accepted
time: 0ms
memory: 8020kb

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:

1995896424
1858609919
1381456401
321041313
291091545
477588347
289709453
361469964
2289570259
1271783177
2804998319
2334689494
6346683
1306086776
1217591019
2931026151
82894799
4113412168
736303075
1741957950
1626950812
1474570427
271372945
890904128
1836210163
2311104502
442130776
1000647155
577626...

result:

ok 65 numbers

Test #6:

score: 0
Wrong Answer
time: 1ms
memory: 8012kb

input:

6
72 4 242374549 242365525
38844937 40032377 18714548 24800811 84693265 75047761 14536480 36314334 58797147 32336071 76679761 75273517 99158666 64125288 82774059 16309377 60419269 62239133 71112327 22351765 87225054 95172626 31326678 103490938 66193376 59895216 49360526 102592480 21448285 9652018 11...

output:

3974462287
4224984385
1733288885
8325997896
5059153478
-4325697003

result:

wrong answer 6th numbers differ - expected: '40261092159', found: '-4325697003'

Subtask #3:

score: 0
Skipped

Dependency #2:

0%

Subtask #4:

score: 11
Accepted

Test #35:

score: 11
Accepted
time: 34ms
memory: 8992kb

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
13
8
3
8
13
3
4
6
10
8
5
11
13
9
14
5
7
5
11
11
4
3
9
7
4
6
5
6
4
5
12
5
9
3
5
10
12
6
6
14
15
4
7
14
14
7
5
7
6
9
5
3
10
8
8
7
6
7
5
11
6
6
5
6
7
4
9
9
9
6
4
4
5
7
6
6
13
6
10
12
5
4
10
14
7
3
7
5
4
7
9
8
13
4
4
8
10
6
6
6
15
10
15
11
3
4
6
7
5
11
13
6
16
13
8
7
10
7
14
11
7
6
9
10
10
8
4
5
7...

result:

ok 66664 numbers

Test #36:

score: 11
Accepted
time: 31ms
memory: 8788kb

input:

6690
72 3 317146495 1
142773247 81913384 80067622 35723743 45518449 71351452 126380141 180273132 191748453 112193322 28442496 150647314 26258521 303990 33345021 6621848 42880826 39589616 204452573 116325570 108705558 11387332 30299069 72815156 15654159 166930094 205234583 104153808 96042862 20541234...

output:

30
10
22
22
15
12
17
13
10
20
11
88
10
14
15
17
40
11
42
11
49
17
14
34
21
13
11
19
9
13
17
12
57
111
12
14
134
23
32
14
47
103
82
14
11
9
34
39
16
15
23
15
92
11
17
11
15
48
16
36
12
17
10
31
13
50
28
17
12
35
19
123
12
15
119
13
36
35
34
15
19
15
15
37
18
11
10
10
117
13
21
58
12
29
56
11
51
40
16...

result:

ok 6690 numbers

Test #37:

score: 11
Accepted
time: 45ms
memory: 6940kb

input:

666
775 2 246425661 1
74622578 157374905 182555425 141672098 9699671 18414135 183998918 97649169 141305719 95187406 180311055 83450992 135739288 129842641 231493124 131315020 85362268 132726174 141564017 176940415 12513491 100929354 136380053 148052188 103349185 8787084 242276294 101926333 233021909...

output:

485
39
54
99
89
32
48
111
35
52
42
202
47
771
55
38
59
26
89
50
31
32
298
36
63
56
251
49
60
80
33
35
34
139
52
48
183
30
451
83
30
35
91
1212
48
33
38
41
40
39
34
42
948
53
41
48
75
106
40
31
60
27
75
105
41
259
370
57
85
209
67
447
83
1350
53
72
74
51
33
30
77
95
49
74
49
40
27
47
459
191
102
187
...

result:

ok 666 numbers

Test #38:

score: 11
Accepted
time: 81ms
memory: 8612kb

input:

65
9836 26 54096694 1
148800 658413 951947 2268744 878783 2182195 752030 2653278 1315450 1670737 1003031 2704024 1562015 1651614 2632695 2596293 928102 3193391 577384 744762 2401049 1562878 1463415 2091183 1946443 2857417 1492929 1055634 346091 2308435 1052429 2600515 197268 3726435 3867526 1509937 ...

output:

398
302
104
198
369
549
174
168
173
300
109
275
1848
665
182
567
88
224
450
893
1083
82
2407
98
3719
111
708
793
180
111
118
137
178
615
133
96
118
155
212
1247
159
341
190
566
274
127
197
95
815
128
272
84
324
392
281
118
12924
192
184
315
113
226
130
107
145

result:

ok 65 numbers

Test #39:

score: 11
Accepted
time: 231ms
memory: 12208kb

input:

7
61099 242 244205595 1
181280 1234639 800705 1545777 714732 1046286 982147 599012 1999703 378865 1631297 162955 1310757 1490341 1653883 890663 489502 319506 1542679 1775914 223824 553169 412031 836021 240362 597557 1771809 1269038 1056897 1170245 993243 1210794 1477083 536484 29428 574562 188428 51...

output:

257
432
950
624
338
2864
510

result:

ok 7 numbers

Test #40:

score: 11
Accepted
time: 987ms
memory: 24204kb

input:

1
500000 670 165989903 1
103760 406913 31838 20661 183387 53344 488074 294844 49288 262521 301494 207516 262808 166192 239240 308454 408885 217096 374103 364624 193230 256683 118826 286820 77107 319769 358900 490649 452977 406234 234381 204738 336194 434184 397247 408167 227027 26992 333880 356080 7...

output:

753

result:

ok 1 number(s): "753"

Test #41:

score: 11
Accepted
time: 267ms
memory: 24472kb

input:

1
500000 161 389959398 1
1545171 2123749 4738724 3504622 2206952 4737593 1492081 2608591 1278248 2427536 420204 349032 2031530 1300377 77074 2421539 2556607 3290337 4208662 3893486 1602657 1845362 1903498 319410 3266603 1395840 3256851 4406268 3362039 1033685 1675968 2190187 4502836 4510964 1272013 ...

output:

3166

result:

ok 1 number(s): "3166"

Test #42:

score: 11
Accepted
time: 37ms
memory: 26624kb

input:

1
500000 8 484270333 1
28988371 105231282 45705068 64269415 98846995 51132992 1380026 74097397 52115820 92745388 48711707 48660103 63278959 105581658 57917738 112161658 67235667 17739390 65786432 84932290 92119788 48751177 86245468 99065485 75023414 2576479 51585902 42714096 34997616 58369597 117902...

output:

68866

result:

ok 1 number(s): "68866"

Test #43:

score: 11
Accepted
time: 404ms
memory: 24476kb

input:

1
500000 258 250937298 1
970934 964404 14674 260332 615136 276442 25915 425152 1706415 814104 267525 482619 269638 163518 770097 672082 962227 324422 614133 1709018 727429 1849863 1429094 75376 1882816 1359939 1364688 1114162 263436 1746849 264568 1297286 1849558 1065682 1075832 1366397 1834968 7517...

output:

1968

result:

ok 1 number(s): "1968"

Test #44:

score: 11
Accepted
time: 327ms
memory: 24220kb

input:

1
500000 212 10375974 1
48414 62026 43365 73298 81433 48797 57100 22005 2464 19388 69422 74446 25996 16554 25804 8648 14720 67088 66937 93324 79934 387 32897 50137 87199 79545 19394 59958 2997 70650 85907 28571 71206 89838 52945 69947 12868 53108 40493 13917 76227 36545 57156 65989 17878 43250 80862...

output:

2397

result:

ok 1 number(s): "2397"

Subtask #5:

score: 0
Skipped

Dependency #1:

100%
Accepted

Dependency #2:

0%