QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#791722#2629. Let's Win the Electionthangthang16 732ms11296kbC++202.9kb2024-11-28 20:33:542024-11-28 20:33:55

Judging History

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

  • [2024-11-28 20:33:55]
  • 评测
  • 测评结果:16
  • 用时:732ms
  • 内存:11296kb
  • [2024-11-28 20:33:54]
  • 提交

answer

// author : thembululquaUwU
// 3.9.2024

#include <bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
#define endl '\n'

using namespace std;
using ll = long long;
using ii = pair <int, int>;
using vi = vector <int>;

const int N = 5e2 + 5;
const int mod = 1e9 + 7;

int n, k;
pair <int, int> state[N];

namespace subtask1{
    const int sub = 105;

    using lb = long double;

    const lb inf = 1e9;

    lb dp[sub][sub][sub];

    void solve(){

        lb ans = inf;

        for (int fix = 0; fix < k; ++ fix){
            for (int i = 0; i <= fix; ++ i){
                for (int j = 0; j <= k - fix; ++ j) dp[0][i][j] = inf;
            }
            dp[0][0][0] = 0;
            for (int i = 1; i <= n; ++ i){
                lb a = state[i].se, b = state[i].fi;
                for (int j = 0; j <= fix; ++ j){
                    for (int t = 0; t <= k - fix; ++ t){
                        dp[i][j][t] = dp[i - 1][j][t];
                        if (t) dp[i][j][t] = min(dp[i][j][t], dp[i - 1][j][t - 1] + a / (fix + 1));
                        if (j && b != -1) dp[i][j][t] = min(dp[i][j][t], dp[i - 1][j - 1][t] + b / j);
                    }
                }
            }

            ans = min(ans, dp[n][fix][k - fix]);
        }

        cout << fixed << setprecision(10) << ans;
    }
}

namespace ac{

    using lb = long double;

    const lb inf = 1e9;

    lb dp[N][N];

    void solve(){

        lb ans = inf;

        for (int fix = 0; fix < k; ++ fix){
            for (int i = 0; i <= n; ++ i)
                for (int j = 1; j <= k; ++ j) dp[i][j] = inf;
            dp[0][0] = 0;
            for (int i = 1; i <= n; ++ i){
                lb a = state[i].se, b = state[i].fi;
                for (int j = 0; j <= min(k, i); ++ j){
                    if (j <= fix){
                        if (j < fix) dp[i][j] = dp[i - 1][j] + a / (fix + 1);
                        if (j && state[i].fi != mod) {
                            dp[i][j] = min(dp[i][j], dp[i - 1][j - 1] + b / j);
                            if (j == fix) dp[i][i] = min(dp[i][i], dp[i][j]);
                        }
                    }
                    else {
                        dp[i][j] = min({dp[i][j], dp[i - 1][j], dp[i - 1][j - 1] + a / (fix + 1)});
                    }
                }
            }

            ans = min(ans, dp[n][k]);
        }

        cout << fixed << setprecision(10) << ans;
    }
}

void solve(){
    cin >> n >> k;
    for (int i = 1; i <= n; ++ i){
        cin >> state[i].se >> state[i].fi;
        if (state[i].fi == -1) state[i].fi = mod;
    }

    sort(state + 1, state + n + 1);

    ac::solve();

    //if (n <= 100) subtask1::solve();
    //else ac::solve();
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    int t = 1; // cin >> t;
    while (t --) solve();
    return 0;
}


Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 5
Accepted

Test #1:

score: 5
Accepted
time: 0ms
memory: 3872kb

input:

1
1
729 -1

output:

729.0000000000

result:

ok error = 0.000000000

Test #2:

score: 5
Accepted
time: 0ms
memory: 3864kb

input:

2
2
204 -1
96 -1

output:

300.0000000000

result:

ok error = 0.000000000

Test #3:

score: 5
Accepted
time: 0ms
memory: 3860kb

input:

3
2
639 -1
597 -1
543 -1

output:

1140.0000000000

result:

ok error = 0.000000000

Test #4:

score: 5
Accepted
time: 0ms
memory: 3872kb

input:

4
3
765 -1
121 -1
409 -1
529 -1

output:

1059.0000000000

result:

ok error = 0.000000000

Test #5:

score: 5
Accepted
time: 6ms
memory: 9020kb

input:

500
50
16 -1
224 -1
562 -1
783 -1
830 -1
455 -1
744 -1
170 -1
196 -1
89 -1
80 -1
357 -1
400 -1
443 -1
690 -1
732 -1
705 -1
735 -1
776 -1
820 -1
992 -1
811 -1
690 -1
364 -1
148 -1
246 -1
535 -1
184 -1
951 -1
86 -1
324 -1
2 -1
842 -1
386 -1
55 -1
571 -1
840 -1
689 -1
538 -1
287 -1
310 -1
322 -1
471 -1...

output:

2580.0000000000

result:

ok error = 0.000000000

Test #6:

score: 5
Accepted
time: 50ms
memory: 9248kb

input:

500
125
567 -1
27 -1
102 -1
783 -1
52 -1
120 -1
732 -1
300 -1
193 -1
772 -1
829 -1
109 -1
699 -1
215 -1
392 -1
193 -1
400 -1
260 -1
559 -1
855 -1
974 -1
935 -1
507 -1
773 -1
481 -1
539 -1
369 -1
588 -1
593 -1
922 -1
28 -1
278 -1
553 -1
525 -1
140 -1
845 -1
637 -1
107 -1
641 -1
130 -1
514 -1
104 -1
9...

output:

15729.0000000000

result:

ok error = 0.000000000

Test #7:

score: 5
Accepted
time: 175ms
memory: 8048kb

input:

500
250
76 -1
295 -1
438 -1
389 -1
573 -1
937 -1
359 -1
81 -1
881 -1
565 -1
620 -1
275 -1
52 -1
572 -1
446 -1
942 -1
338 -1
684 -1
657 -1
616 -1
156 -1
648 -1
492 -1
168 -1
711 -1
348 -1
715 -1
868 -1
29 -1
509 -1
483 -1
658 -1
183 -1
214 -1
733 -1
566 -1
388 -1
962 -1
850 -1
44 -1
191 -1
743 -1
143...

output:

66687.0000000000

result:

ok error = 0.000000000

Test #8:

score: 5
Accepted
time: 346ms
memory: 8596kb

input:

500
375
565 -1
295 -1
459 -1
572 -1
658 -1
810 -1
178 -1
13 -1
644 -1
975 -1
150 -1
220 -1
557 -1
156 -1
573 -1
543 -1
325 -1
62 -1
427 -1
599 -1
204 -1
6 -1
892 -1
590 -1
801 -1
338 -1
367 -1
311 -1
890 -1
172 -1
606 -1
300 -1
806 -1
150 -1
814 -1
97 -1
712 -1
769 -1
583 -1
792 -1
24 -1
384 -1
136 ...

output:

147876.0000000000

result:

ok error = 0.000000000

Test #9:

score: 5
Accepted
time: 539ms
memory: 9872kb

input:

500
500
187 -1
429 -1
984 -1
572 -1
718 -1
162 -1
355 -1
922 -1
180 -1
457 -1
881 -1
946 -1
105 -1
273 -1
3 -1
891 -1
290 -1
281 -1
598 -1
432 -1
279 -1
471 -1
123 -1
212 -1
290 -1
975 -1
796 -1
438 -1
43 -1
371 -1
229 -1
121 -1
912 -1
317 -1
41 -1
445 -1
307 -1
777 -1
336 -1
320 -1
699 -1
617 -1
23...

output:

249562.0000000000

result:

ok error = 0.000000000

Test #10:

score: 5
Accepted
time: 313ms
memory: 8792kb

input:

500
350
1000 -1
1000 -1
1000 -1
1000 -1
1000 -1
1000 -1
1000 -1
1000 -1
1000 -1
1000 -1
1000 -1
1000 -1
1000 -1
1000 -1
1000 -1
1000 -1
1000 -1
1000 -1
1000 -1
1000 -1
1000 -1
1000 -1
1000 -1
1000 -1
1000 -1
1000 -1
1000 -1
1000 -1
1000 -1
1000 -1
1000 -1
1000 -1
1000 -1
1000 -1
1000 -1
1000 -1
1000...

output:

350000.0000000000

result:

ok error = 0.000000000

Subtask #2:

score: 0
Wrong Answer

Test #11:

score: 5
Accepted
time: 0ms
memory: 3916kb

input:

1
1
791 791

output:

791.0000000000

result:

ok error = 0.000000000

Test #12:

score: 5
Accepted
time: 87ms
memory: 8976kb

input:

500
150
824 824
524 524
20 20
713 713
668 668
342 342
53 53
660 660
180 180
614 614
504 504
216 216
200 200
551 551
660 660
696 696
194 194
820 820
517 517
209 209
484 484
744 744
904 904
268 268
931 931
265 265
701 701
511 511
591 591
443 443
374 374
296 296
848 848
481 481
771 771
521 521
687 687
...

output:

341.0793145790

result:

ok error = 0.000000000

Test #13:

score: 0
Wrong Answer
time: 78ms
memory: 11296kb

input:

500
150
187 -1
798 798
819 819
927 927
9 -1
742 742
268 -1
453 -1
132 132
947 947
683 -1
156 -1
809 -1
681 -1
472 472
656 -1
177 177
347 347
102 102
45 45
215 -1
580 580
371 371
807 807
625 625
11 11
596 596
34 -1
803 803
360 360
45 -1
613 613
490 -1
871 -1
974 -1
710 -1
308 308
698 -1
117 117
962 -...

output:

355.9601652030

result:

wrong answer read 355.960165203 but expected 355.342286415, error = 0.617878788

Subtask #3:

score: 0
Wrong Answer

Test #21:

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

input:

7
1
309 988
195 951
51 -1
104 279
498 906
410 498
76 -1

output:

51.0000000000

result:

ok error = 0.000000000

Test #22:

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

input:

7
2
299 867
879 943
170 -1
142 847
219 249
48 119
20 813

output:

68.0000000000

result:

ok error = 0.000000000

Test #23:

score: 0
Wrong Answer
time: 0ms
memory: 3896kb

input:

7
3
150 170
124 765
351 855
139 -1
182 -1
427 531
945 -1

output:

413.0000000000

result:

wrong answer read 413.000000000 but expected 301.500000000, error = 111.500000000

Subtask #4:

score: 0
Wrong Answer

Test #36:

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

input:

20
3
43 487
143 720
123 886
88 266
639 739
129 522
300 696
88 889
276 550
653 722
92 157
85 674
452 666
290 517
780 801
49 430
633 932
197 421
20 749
286 479

output:

112.0000000000

result:

ok error = 0.000000000

Test #37:

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

input:

20
9
30 114
174 185
50 580
851 893
525 729
167 804
13 48
614 700
244 933
348 357
97 970
539 879
339 344
275 430
619 979
810 847
108 896
590 619
214 343
189 662

output:

372.9166666667

result:

ok error = 0.000000000

Test #38:

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

input:

20
9
208 346
207 411
259 509
644 -1
215 798
335 527
892 998
923 -1
342 639
576 858
275 460
238 951
646 693
820 996
628 -1
461 888
135 395
618 815
370 969
84 812

output:

1021.3333333333

result:

ok error = 0.000000000

Test #39:

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

input:

20
13
81 479
143 725
64 217
153 772
35 263
148 966
92 364
595 835
108 604
320 631
356 997
359 724
49 799
56 992
178 426
36 838
69 500
440 985
211 850
339 680

output:

719.5000000000

result:

ok error = 0.000000000

Test #40:

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

input:

20
13
553 807
91 241
34 935
168 -1
563 641
809 855
877 -1
371 920
302 755
70 517
378 403
646 838
870 977
491 -1
71 263
817 -1
263 427
178 265
270 585
512 891

output:

997.5309523810

result:

ok error = 0.000000000

Test #41:

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

input:

20
13
927 992
102 320
91 585
414 622
417 853
68 402
528 -1
89 595
612 684
542 -1
165 224
379 -1
327 829
332 859
486 715
455 523
598 -1
791 791
680 -1
373 -1

output:

1174.0071428571

result:

ok error = 0.000000000

Test #42:

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

input:

20
14
100 421
95 842
205 940
250 955
465 975
276 903
209 549
354 400
60 617
241 340
131 446
329 633
469 610
335 917
96 979
108 794
321 628
154 801
805 816
354 523

output:

1127.8833333333

result:

ok error = 0.000000000

Test #43:

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

input:

20
14
902 908
637 708
347 471
624 712
79 -1
923 -1
398 588
355 808
802 868
284 892
129 974
958 -1
811 -1
735 912
483 806
114 999
439 874
247 855
258 820
825 872

output:

1750.6000000000

result:

ok error = 0.000000000

Test #44:

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

input:

20
14
83 -1
620 743
854 -1
581 844
2 79
739 -1
375 -1
185 367
100 139
440 471
569 -1
36 330
421 967
190 615
323 -1
155 325
6 -1
187 838
102 704
341 -1

output:

716.6166666667

result:

ok error = 0.000000000

Test #45:

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

input:

20
20
190 949
208 236
517 597
261 438
442 567
52 458
464 595
135 236
917 963
491 855
25 890
324 950
301 826
375 801
142 474
109 146
84 378
29 541
602 633
438 786

output:

1160.7068181818

result:

ok error = 0.000000000

Test #46:

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

input:

20
20
454 734
194 957
163 811
273 526
614 753
709 882
528 964
437 460
238 333
443 580
662 810
227 430
289 355
241 985
973 -1
823 914
499 942
291 557
521 -1
321 743

output:

1727.1043456543

result:

ok error = 0.000000000

Test #47:

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

input:

20
13
58 956
58 943
50 913
86 939
16 1000
91 914
19 1000
94 903
30 951
79 899
14 1000
103 929
33 1000
85 939
26 1000
33 982
99 896
78 944
75 939
100 945

output:

569.0000000000

result:

ok error = 0.000000000

Test #48:

score: 0
Wrong Answer
time: 0ms
memory: 3892kb

input:

20
14
167 790
133 905
164 791
135 906
135 833
202 765
227 778
213 771
213 832
253 764
200 809
172 844
137 823
157 890
220 828
171 853
198 813
130 898
230 802
229 786

output:

1783.1666666667

result:

wrong answer read 1783.166666667 but expected 1779.500000000, error = 3.666666667

Subtask #5:

score: 0
Wrong Answer

Test #61:

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

input:

100
15
824 961
637 866
334 751
463 701
28 953
68 168
589 741
107 298
690 754
20 869
686 990
151 659
90 234
279 477
210 337
481 626
347 916
428 580
445 708
239 584
306 495
932 978
84 896
39 199
498 609
308 668
301 605
275 664
426 444
220 345
429 488
365 698
364 681
57 156
129 824
166 931
412 855
745 ...

output:

327.0000000000

result:

wrong answer read 327.000000000 but expected 324.333333333, error = 2.666666667

Subtask #6:

score: 11
Accepted

Test #81:

score: 11
Accepted
time: 723ms
memory: 9868kb

input:

500
500
215 315
169 657
849 974
865 984
799 919
681 905
236 828
612 980
342 741
203 235
955 997
456 691
358 1000
617 965
691 912
10 295
426 646
72 725
242 788
171 742
256 696
157 347
151 397
229 798
323 427
133 368
833 993
266 525
254 915
371 438
700 889
235 654
400 953
52 277
31 562
15 298
244 383
...

output:

1767.1975007973

result:

ok error = 0.000000000

Test #82:

score: 11
Accepted
time: 725ms
memory: 9564kb

input:

500
500
205 643
330 716
239 703
264 305
223 429
319 806
279 764
538 850
908 938
357 944
583 968
376 927
593 597
882 947
249 254
770 794
231 553
215 518
448 887
699 964
484 538
314 583
565 648
342 703
554 869
667 814
264 953
269 902
292 546
234 943
375 705
488 637
238 933
363 466
532 966
233 738
637 ...

output:

2763.3815674113

result:

ok error = 0.000000000

Test #83:

score: 11
Accepted
time: 718ms
memory: 9308kb

input:

500
500
621 820
492 921
496 917
602 719
670 831
533 828
616 764
790 923
907 994
732 854
428 715
448 485
666 970
695 959
446 865
552 582
556 670
421 569
576 871
696 793
618 982
484 838
558 680
475 601
657 890
452 795
639 864
640 967
821 995
489 937
922 990
623 868
444 719
401 887
442 690
403 822
444 ...

output:

3763.0435188736

result:

ok error = 0.000000000

Test #84:

score: 11
Accepted
time: 721ms
memory: 8116kb

input:

500
500
806 904
712 941
724 822
850 985
844 899
910 932
705 835
715 907
727 895
659 703
839 887
819 828
772 785
723 774
680 872
726 928
690 797
770 891
673 884
836 857
728 973
630 963
816 967
865 972
627 918
651 695
652 843
799 929
779 795
885 974
807 854
707 991
786 914
678 805
682 785
859 864
649 ...

output:

4840.5411729334

result:

ok error = 0.000000000

Test #85:

score: 11
Accepted
time: 732ms
memory: 9484kb

input:

500
500
801 849
901 999
849 921
925 999
864 992
851 989
907 967
853 923
840 912
816 877
853 878
825 893
909 992
824 914
854 902
961 981
871 905
812 985
800 981
902 998
943 991
818 967
899 999
811 878
815 968
919 990
896 994
805 870
833 892
809 895
850 982
863 984
828 850
835 953
860 973
825 876
896 ...

output:

5820.4909981528

result:

ok error = 0.000000000

Test #86:

score: 11
Accepted
time: 716ms
memory: 7876kb

input:

500
500
298 693
393 595
298 660
327 678
293 668
374 585
369 629
346 615
319 702
308 678
333 708
335 656
274 748
333 709
368 665
289 707
315 635
338 623
262 777
304 740
281 742
266 695
314 712
271 752
308 655
304 665
298 677
326 665
328 701
268 716
307 737
247 736
248 702
322 669
361 603
282 736
317 ...

output:

3946.9244817827

result:

ok error = 0.000000000

Test #87:

score: 11
Accepted
time: 721ms
memory: 9688kb

input:

500
500
431 590
318 561
389 581
897 976
980 980
659 799
431 641
517 675
732 800
688 810
891 960
685 779
464 686
464 607
831 874
205 517
932 1000
555 719
666 758
306 546
593 752
257 550
923 968
839 907
932 979
422 579
865 865
941 977
499 692
618 789
628 793
630 766
655 761
931 991
482 617
638 786
663...

output:

3878.5527203058

result:

ok error = 0.000000000

Subtask #7:

score: 0
Wrong Answer

Test #88:

score: 23
Accepted
time: 12ms
memory: 8108kb

input:

500
50
170 253
450 885
684 995
425 830
76 273
249 856
188 360
410 635
457 765
184 217
364 807
74 675
504 883
768 975
714 814
222 922
144 940
704 878
780 949
256 325
113 997
436 692
683 812
154 655
227 816
666 750
645 940
537 579
267 671
474 972
188 403
65 459
606 671
375 495
590 722
238 998
157 790
...

output:

368.1297619048

result:

ok error = 0.000000000

Test #89:

score: 0
Wrong Answer
time: 9ms
memory: 8180kb

input:

500
50
621 709
721 966
896 937
884 911
865 993
714 915
736 840
740 753
615 796
717 976
825 872
622 788
955 964
903 983
882 972
643 797
648 826
648 855
784 839
871 935
683 813
885 968
706 707
636 844
896 933
737 743
629 909
905 936
688 957
712 767
972 983
678 900
633 731
683 985
843 987
689 835
812 9...

output:

2882.6169127473

result:

wrong answer read 2882.616912747 but expected 2882.474582304, error = 0.142330443