QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#343273#8249. Lines Per HourMayaZayn#AC ✓195ms299168kbC++141.3kb2024-03-02 12:56:522024-03-02 12:56:52

Judging History

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

  • [2024-03-02 12:56:52]
  • 评测
  • 测评结果:AC
  • 用时:195ms
  • 内存:299168kb
  • [2024-03-02 12:56:52]
  • 提交

answer

#include <bits/stdc++.h>
#define MayaZayn ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define ll long long
#define endl '\n'
#define all(x) (x).begin(), (x).end()
#define all_r(x) (x).rbegin(), (x).rend()
#define mnEl(vec) *min_element(vec.begin(), vec.end())
#define mxEl(vec) *max_element(vec.begin(), vec.end())
#define yes cout << "YES"
#define no cout << "NO"
#define in(v) for (auto & x : v) cin >> x
#define out(v) for (auto & x : v) cout << x << ' '
#define inLL(v) for (ll & x : v) cin >> x
#define openIn(x) freopen(x, "r", stdin);
#define openOut(x) freopen(x, "w", stdout);
#define M 1000000007
#define N 25005

using namespace std;

int dp[55][N][55], n, lph;
vector<int> v;

int rec(int i, int sum, int cnt) {
    if (sum >= 0 && i == n)
        return cnt;
    if (sum < 0)
        return INT_MIN;

    int &ret = dp[i][sum][cnt];
    if (~ret)
        return ret;

    ret = 0;
    ret = max({rec(i + 1, sum, cnt), rec(i + 1, sum - v[i], cnt + 1), ret});

    return ret;
}

void solve() {
    memset(dp, -1, sizeof dp);
    cin >> n >> lph;
    v.resize(n);
    in(v);
    cout << rec(0, lph*5, 0);
}

int main() {
    MayaZayn

//    int t;
//    cin >> t;
//    while (t--)
        solve();

    return 0;
}

详细

Test #1:

score: 100
Accepted
time: 15ms
memory: 299112kb

input:

10 100
30
300
1000
20
35
19
84
117
212
98

output:

7

result:

ok single line: '7'

Test #2:

score: 0
Accepted
time: 12ms
memory: 299036kb

input:

50 999
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100

output:

49

result:

ok single line: '49'

Test #3:

score: 0
Accepted
time: 11ms
memory: 299152kb

input:

50 500
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100

output:

25

result:

ok single line: '25'

Test #4:

score: 0
Accepted
time: 4ms
memory: 299112kb

input:

50 20
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100

output:

1

result:

ok single line: '1'

Test #5:

score: 0
Accepted
time: 3ms
memory: 299084kb

input:

50 5
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100

output:

0

result:

ok single line: '0'

Test #6:

score: 0
Accepted
time: 16ms
memory: 299168kb

input:

50 5000
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100

output:

50

result:

ok single line: '50'

Test #7:

score: 0
Accepted
time: 7ms
memory: 299128kb

input:

50 5000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000
1000

output:

25

result:

ok single line: '25'

Test #8:

score: 0
Accepted
time: 195ms
memory: 299024kb

input:

50 5000
950
62
49
537
539
427
182
686
698
933
596
257
417
149
85
162
183
276
190
497
368
244
49
216
445
292
983
528
944
854
157
903
13
774
190
11
595
297
270
406
266
856
830
638
311
855
35
143
699
558

output:

50

result:

ok single line: '50'

Test #9:

score: 0
Accepted
time: 172ms
memory: 299032kb

input:

50 5000
641
631
306
300
437
581
95
987
881
159
948
916
272
527
78
680
129
274
456
584
648
21
534
425
431
540
386
911
661
288
92
189
909
187
361
287
959
699
94
748
795
905
238
179
297
438
719
488
630
689

output:

50

result:

ok single line: '50'

Test #10:

score: 0
Accepted
time: 180ms
memory: 299104kb

input:

50 5000
3
131
169
895
787
590
620
255
413
337
462
937
350
620
557
482
426
456
369
350
432
962
875
595
659
229
924
94
939
347
746
333
667
616
397
864
91
51
960
493
693
673
803
718
108
88
517
560
217
541

output:

49

result:

ok single line: '49'

Test #11:

score: 0
Accepted
time: 194ms
memory: 299072kb

input:

50 5000
431
11
448
418
428
593
991
47
964
229
598
740
312
882
25
985
152
285
675
915
951
943
509
195
8
411
332
451
282
609
585
8
743
932
721
599
698
950
533
214
471
910
580
608
644
483
44
403
845
312

output:

48

result:

ok single line: '48'

Test #12:

score: 0
Accepted
time: 175ms
memory: 299032kb

input:

50 5000
375
898
446
820
722
210
849
549
761
396
319
864
70
734
811
999
761
902
490
903
401
220
567
125
145
498
539
677
581
635
633
503
19
669
768
70
95
20
993
502
47
812
704
826
237
675
664
663
723
849

output:

47

result:

ok single line: '47'

Test #13:

score: 0
Accepted
time: 83ms
memory: 299024kb

input:

50 1703
531
896
869
44
617
801
437
900
628
159
365
976
300
71
59
78
671
346
945
546
320
881
432
608
164
983
125
825
745
820
516
688
409
770
617
952
581
926
270
972
525
772
885
154
187
31
7
764
175
252

output:

28

result:

ok single line: '28'

Test #14:

score: 0
Accepted
time: 7ms
memory: 299120kb

input:

50 166
797
933
482
749
773
291
16
719
953
182
610
828
330
388
242
504
480
925
711
294
26
227
653
675
589
920
448
940
927
534
486
73
351
889
905
155
747
617
37
456
124
260
204
744
746
560
611
712
200
278

output:

8

result:

ok single line: '8'

Test #15:

score: 0
Accepted
time: 168ms
memory: 299116kb

input:

50 4945
739
12
90
476
680
117
847
71
367
825
823
468
485
706
800
674
448
237
491
531
996
375
421
501
411
571
480
363
779
596
204
823
289
444
719
502
251
759
732
736
187
911
999
162
896
180
783
10
623
736

output:

48

result:

ok single line: '48'

Test #16:

score: 0
Accepted
time: 151ms
memory: 299120kb

input:

50 2812
46
950
516
647
122
73
962
41
740
974
153
620
981
890
302
725
351
246
646
523
773
525
660
626
60
444
72
816
724
716
215
128
58
924
777
125
22
606
227
606
995
964
233
88
904
916
48
801
291
463

output:

37

result:

ok single line: '37'

Test #17:

score: 0
Accepted
time: 80ms
memory: 299080kb

input:

50 1597
920
693
71
510
819
142
110
651
896
461
372
871
365
331
408
481
875
941
351
10
236
173
875
858
749
500
946
76
503
894
640
946
624
153
455
750
670
3
202
71
844
608
537
388
245
429
79
240
964
708

output:

28

result:

ok single line: '28'

Test #18:

score: 0
Accepted
time: 4ms
memory: 299112kb

input:

23 147
179
396
11
249
245
668
830
927
704
150
458
28
896
924
907
993
881
287
268
197
645
699
995

output:

5

result:

ok single line: '5'

Test #19:

score: 0
Accepted
time: 35ms
memory: 299100kb

input:

42 1173
423
57
606
532
252
989
112
879
840
776
117
777
549
459
104
891
970
20
170
369
422
992
722
239
916
242
805
554
536
178
70
491
260
457
666
806
111
88
898
665
515
920

output:

22

result:

ok single line: '22'

Test #20:

score: 0
Accepted
time: 76ms
memory: 299128kb

input:

44 2352
425
707
979
829
195
834
80
180
590
905
819
493
514
909
435
43
608
629
929
841
703
414
592
636
226
1000
950
884
73
366
198
692
819
251
236
632
61
752
844
326
866
26
439
14

output:

30

result:

ok single line: '30'

Test #21:

score: 0
Accepted
time: 36ms
memory: 299144kb

input:

32 3808
195
819
880
522
181
499
388
572
214
283
419
458
271
636
416
358
146
730
887
845
751
98
227
848
824
859
780
135
874
742
540
975

output:

32

result:

ok single line: '32'

Test #22:

score: 0
Accepted
time: 7ms
memory: 299140kb

input:

8 4504
5
907
437
398
457
672
270
87

output:

8

result:

ok single line: '8'

Test #23:

score: 0
Accepted
time: 11ms
memory: 299076kb

input:

50 1000
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100

output:

50

result:

ok single line: '50'