QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#478250#2629. Let's Win the Electionsnpmrnhlol10 1ms5972kbC++141.1kb2024-07-14 19:38:492024-07-14 19:38:49

Judging History

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

  • [2024-07-14 19:38:49]
  • 评测
  • 测评结果:10
  • 用时:1ms
  • 内存:5972kb
  • [2024-07-14 19:38:49]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll N = 2e5;
const ll inf = 1e18;
struct state{
    ll a,b;
}v[N];
int p[N],p2[N];
multiset <ll> pos;
int main(){
    cout<<fixed<<setprecision(69);
    int n,k;
    cin>>n>>k;
    for(int i = 0;i < n;i++){
        cin>>v[i].a>>v[i].b;
        if(v[i].b == -1)v[i].b = inf;
        p[i] = i;
        p2[i] = i;
    }
    sort(p,p + n,[&](int a, int b){
         return v[a].a < v[b].a;
    });
    sort(p2,p2 + n,[&](int a, int b){
         return v[a].b < v[b].b;
    });
    ld costb = 0;
    ll costa = 0;
    for(int i = 0;i < k;i++){
        pos.insert(v[p[i]].a);
        costa+=v[p[i]].a;
    }
    ld ans = costa;
    for(int i = 0;i < k;i++){
        ///add it
        costb+=(ld)v[p2[i]].b/(i + 1);
        if(pos.find(v[p2[i]].a) != pos.end()){
            costa-=v[p2[i]].a;
            pos.erase(pos.find(v[p2[i]].a));
        }else{
            costa-=*pos.rbegin();
            pos.erase(prev(pos.end()));
        }
        ans = min(ans,(ld)costb + (ld)costa/(i + 2));
    }
    cout<<ans;
    return 0;
}

詳細信息

Subtask #1:

score: 5
Accepted

Test #1:

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

input:

1
1
729 -1

output:

729.000000000000000000000000000000000000000000000000000000000000000000000

result:

ok error = 0.000000000

Test #2:

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

input:

2
2
204 -1
96 -1

output:

300.000000000000000000000000000000000000000000000000000000000000000000000

result:

ok error = 0.000000000

Test #3:

score: 0
Accepted
time: 1ms
memory: 5904kb

input:

3
2
639 -1
597 -1
543 -1

output:

1140.000000000000000000000000000000000000000000000000000000000000000000000

result:

ok error = 0.000000000

Test #4:

score: 0
Accepted
time: 0ms
memory: 3896kb

input:

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

output:

1059.000000000000000000000000000000000000000000000000000000000000000000000

result:

ok error = 0.000000000

Test #5:

score: 0
Accepted
time: 1ms
memory: 5932kb

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.000000000000000000000000000000000000000000000000000000000000000000000

result:

ok error = 0.000000000

Test #6:

score: 0
Accepted
time: 0ms
memory: 5908kb

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.000000000000000000000000000000000000000000000000000000000000000000000

result:

ok error = 0.000000000

Test #7:

score: 0
Accepted
time: 1ms
memory: 3912kb

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.000000000000000000000000000000000000000000000000000000000000000000000

result:

ok error = 0.000000000

Test #8:

score: 0
Accepted
time: 1ms
memory: 5872kb

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.000000000000000000000000000000000000000000000000000000000000000000000

result:

ok error = 0.000000000

Test #9:

score: 0
Accepted
time: 1ms
memory: 5972kb

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.000000000000000000000000000000000000000000000000000000000000000000000

result:

ok error = 0.000000000

Test #10:

score: 0
Accepted
time: 1ms
memory: 5940kb

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.000000000000000000000000000000000000000000000000000000000000000000000

result:

ok error = 0.000000000

Subtask #2:

score: 5
Accepted

Test #11:

score: 5
Accepted
time: 1ms
memory: 5904kb

input:

1
1
791 791

output:

791.000000000000000000000000000000000000000000000000000000000000000000000

result:

ok error = 0.000000000

Test #12:

score: 0
Accepted
time: 1ms
memory: 5908kb

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.079314578951172470810959680420637596398591995239257812500000000000000

result:

ok error = 0.000000000

Test #13:

score: 0
Accepted
time: 1ms
memory: 5900kb

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.342286415133878696437363942095544189214706420898437500000000000000000

result:

ok error = 0.000000000

Test #14:

score: 0
Accepted
time: 0ms
memory: 3876kb

input:

500
150
910 -1
793 -1
374 374
413 -1
153 153
344 -1
604 -1
793 -1
799 -1
669 669
464 -1
135 135
828 -1
334 -1
983 -1
844 844
443 -1
862 862
589 -1
486 -1
517 517
284 284
962 962
771 771
84 -1
211 211
957 -1
944 944
103 -1
545 -1
394 -1
711 -1
283 -1
317 -1
171 -1
933 -1
857 -1
424 -1
343 -1
746 -1
1...

output:

940.689688879509464336514668048039311543107032775878906250000000000000000

result:

ok error = 0.000000000

Test #15:

score: 0
Accepted
time: 1ms
memory: 5860kb

input:

500
350
444 444
264 264
650 650
694 694
794 794
692 692
20 20
753 753
881 881
31 31
951 951
906 906
321 321
741 741
275 275
467 467
848 848
200 200
378 378
560 560
253 253
949 949
536 536
695 695
478 478
804 804
250 250
106 106
757 757
160 160
641 641
189 189
546 546
900 900
619 619
938 938
804 804
...

output:

707.046228150463192840824433460511500015854835510253906250000000000000000

result:

ok error = 0.000000000

Test #16:

score: 0
Accepted
time: 1ms
memory: 5964kb

input:

500
350
443 443
806 806
115 -1
954 954
359 -1
608 608
632 632
736 -1
550 550
388 -1
617 617
301 -1
314 314
459 -1
250 -1
84 84
42 42
716 -1
98 98
234 234
620 620
755 755
958 -1
826 826
564 -1
115 -1
183 183
691 691
741 741
309 309
359 -1
916 -1
760 760
759 759
752 752
779 -1
671 671
176 176
163 163
...

output:

982.134559205841725759711380305816419422626495361328125000000000000000000

result:

ok error = 0.000000000

Test #17:

score: 0
Accepted
time: 1ms
memory: 5920kb

input:

500
350
670 -1
837 -1
828 828
945 -1
256 256
780 -1
546 -1
602 602
219 -1
286 -1
927 927
836 -1
878 878
995 -1
346 -1
245 -1
709 -1
692 -1
519 -1
121 -1
419 -1
914 914
660 660
480 -1
738 -1
116 -1
612 -1
665 -1
57 57
891 -1
626 -1
195 -1
684 -1
625 -1
913 -1
438 -1
582 -1
70 70
35 -1
758 -1
141 141
...

output:

1956.186568804695206980071020552713889628648757934570312500000000000000000

result:

ok error = 0.000000000

Test #18:

score: 0
Accepted
time: 1ms
memory: 5892kb

input:

500
500
451 451
72 72
216 216
601 601
431 431
326 326
614 614
774 774
459 459
130 130
241 241
523 523
130 130
519 519
726 726
722 722
309 309
969 969
584 584
189 189
210 210
668 668
498 498
390 390
243 243
188 188
752 752
835 835
864 864
177 177
427 427
19 19
51 51
225 225
398 398
1000 1000
740 740
...

output:

1043.237084576540680269651772960060043260455131530761718750000000000000000

result:

ok error = 0.000000000

Test #19:

score: 0
Accepted
time: 0ms
memory: 5872kb

input:

500
500
488 488
883 -1
875 875
81 81
528 528
588 588
310 -1
363 363
764 -1
773 773
958 -1
545 545
761 -1
108 -1
625 625
986 986
314 314
496 496
813 813
480 -1
663 -1
777 777
849 849
418 -1
834 834
168 168
854 -1
177 177
24 -1
318 -1
631 -1
698 -1
449 449
238 -1
825 -1
318 318
107 -1
816 816
705 -1
5...

output:

1370.744890556792839442223908008600119501352310180664062500000000000000000

result:

ok error = 0.000000000

Test #20:

score: 0
Accepted
time: 1ms
memory: 3944kb

input:

500
500
306 -1
168 168
563 -1
966 -1
906 -1
719 -1
608 -1
587 -1
405 -1
752 -1
723 -1
330 -1
326 -1
622 -1
662 -1
930 -1
20 -1
367 -1
113 -1
851 -1
212 -1
863 -1
479 -1
838 838
743 743
854 -1
392 -1
381 -1
673 673
881 -1
870 -1
72 -1
218 -1
502 -1
649 -1
724 -1
279 -1
672 -1
811 811
836 -1
722 -1
79...

output:

3138.957629833516511874691445882490370422601699829101562500000000000000000

result:

ok error = 0.000000000

Subtask #3:

score: 0
Wrong Answer

Test #21:

score: 11
Accepted
time: 1ms
memory: 5932kb

input:

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

output:

51.000000000000000000000000000000000000000000000000000000000000000000000

result:

ok error = 0.000000000

Test #22:

score: 0
Accepted
time: 0ms
memory: 5716kb

input:

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

output:

68.000000000000000000000000000000000000000000000000000000000000000000000

result:

ok error = 0.000000000

Test #23:

score: 0
Accepted
time: 0ms
memory: 5864kb

input:

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

output:

301.500000000000000000000000000000000000000000000000000000000000000000000

result:

ok error = 0.000000000

Test #24:

score: 0
Accepted
time: 0ms
memory: 5904kb

input:

7
4
20 385
428 551
324 347
392 940
587 840
756 992
73 417

output:

589.500000000000000000000000000000000000000000000000000000000000000000000

result:

ok error = 0.000000000

Test #25:

score: 0
Accepted
time: 0ms
memory: 5908kb

input:

7
5
109 831
41 900
289 743
187 413
77 355
407 427
103 694

output:

517.000000000000000000000000000000000000000000000000000000000000000000000

result:

ok error = 0.000000000

Test #26:

score: 0
Accepted
time: 0ms
memory: 5716kb

input:

7
6
72 970
136 440
497 824
445 762
137 424
200 575
101 437

output:

901.000000000000000000000000000000000000000000000000000000000000000000000

result:

ok error = 0.000000000

Test #27:

score: 0
Accepted
time: 1ms
memory: 5860kb

input:

7
7
339 840
105 640
121 232
347 387
294 514
421 711
516 812

output:

942.083333333333333314829616256247390992939472198486328125000000000000000

result:

ok error = 0.000000000

Test #28:

score: 0
Accepted
time: 1ms
memory: 5864kb

input:

7
5
168 792
231 784
196 761
129 876
172 846
216 740
237 734

output:

881.000000000000000000000000000000000000000000000000000000000000000000000

result:

ok error = 0.000000000

Test #29:

score: -11
Wrong Answer
time: 0ms
memory: 3868kb

input:

7
5
393 646
375 666
374 676
320 635
288 668
284 758
333 702

output:

1259.666666666666666629659232512494781985878944396972656250000000000000000

result:

wrong answer read 1259.666666667 but expected 1258.500000000, error = 1.166666667

Subtask #4:

score: 0
Wrong Answer

Test #36:

score: 12
Accepted
time: 1ms
memory: 5908kb

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.000000000000000000000000000000000000000000000000000000000000000000000

result:

ok error = 0.000000000

Test #37:

score: 0
Accepted
time: 1ms
memory: 5952kb

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.916666666666666685170383743752609007060527801513671875000000000000000

result:

ok error = 0.000000000

Test #38:

score: -12
Wrong Answer
time: 0ms
memory: 3764kb

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.700000000000000011102230246251565404236316680908203125000000000000000

result:

wrong answer read 1021.700000000 but expected 1021.333333333, error = 0.366666667

Subtask #5:

score: 0
Wrong Answer

Test #61:

score: 33
Accepted
time: 1ms
memory: 5872kb

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:

324.333333333333333314829616256247390992939472198486328125000000000000000

result:

ok error = 0.000000000

Test #62:

score: 0
Accepted
time: 0ms
memory: 5712kb

input:

100
15
699 980
501 508
700 814
511 619
535 922
883 962
945 -1
686 735
858 884
819 -1
904 966
828 -1
755 766
657 980
633 679
620 867
553 809
900 996
515 819
969 -1
994 -1
898 902
572 704
820 -1
832 -1
768 831
660 845
609 840
578 -1
766 978
723 852
663 934
728 929
660 667
729 990
773 852
654 691
603 -...

output:

1892.320526695526695548643658639775821939110755920410156250000000000000000

result:

ok error = 0.000000000

Test #63:

score: -33
Wrong Answer
time: 1ms
memory: 5868kb

input:

100
30
158 260
214 701
448 516
193 925
222 372
325 419
192 680
52 712
750 865
409 445
98 304
694 802
100 452
446 562
232 986
27 723
475 675
404 497
99 743
274 402
81 703
134 147
493 551
504 821
192 688
503 958
432 500
761 917
26 207
152 292
443 891
635 811
73 241
539 645
679 961
115 380
343 475
445 ...

output:

646.739682539682539663683513708747341297566890716552734375000000000000000

result:

wrong answer read 646.739682540 but expected 646.342857143, error = 0.396825397

Subtask #6:

score: 0
Wrong Answer

Test #81:

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

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:

1849.235133879482481211731226267147576436400413513183593750000000000000000

result:

wrong answer read 1849.235133879 but expected 1767.197500797, error = 82.037633082

Subtask #7:

score: 0
Wrong Answer

Test #88:

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

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:

369.719047619047619046561692357499850913882255554199218750000000000000000

result:

wrong answer read 369.719047619 but expected 368.129761905, error = 1.589285714