QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#424408#2629. Let's Win the ElectionAdorable0 74ms79756kbC++231.8kb2024-05-29 09:34:542024-05-29 09:34:54

Judging History

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

  • [2024-05-29 09:34:54]
  • 评测
  • 测评结果:0
  • 用时:74ms
  • 内存:79756kb
  • [2024-05-29 09:34:54]
  • 提交

answer

#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define em emplace_back
#define F(i,x,y) for(int i=x;i<=y;i++)
#define G(i,x,y) for(int i=x;i>=y;i--)
#define W(G,i,x) for(auto&i:G[x])
#define W_(G,i,j,x) for(auto&[i,j]:G[x])
#define add(x,y) z[x].em(y)
#define add_(x,y) add(x,y),add(y,x)
#define Add(x,y,d) z[x].em(y,d)
#define Add_(x,y,z) Add(x,y,z),Add(y,x,z);
#ifdef int
#define inf (7611257611378358090ll/2)
#else
#define inf 0x3f3f3f3f
#endif
using namespace std;
const int N = 3010, mod = 1e9 + 7;
struct Node {
    double a, b;
    bool operator<(const Node &r) const {
        return a < r.a || a == r.a && b < r.b;
    }
} z[N];
double f[N][N], suf[N][N];
auto main() [[O3]] -> signed {
    int n, k;
    cin >> n >> k;
    F(i, 1, n) {
        cin >> z[i].a >> z[i].b;
        if (z[i].b < 0) {
            z[i].b = inf;
        }
    }
    sort(z + 1, z + n + 1);
    G(i, n, 1) {
        vector<Node> v;
        G(j, n, i) {
            v.pb(z[j]);
        }
        sort(v.begin(), v.end());
        F(j, 0, (int)v.size() - 1) {
            suf[i][j + 1] = suf[i][j] + z[j].a;
        }
    }
    F(i, 0, N - 1) {
        F(j, 0, N - 1) {
            f[i][j] = inf;
        }
    }
    f[0][0] = 0;
    double mi = inf;
    F(_, 0, k) {
        F(i, 1, k) {
            F(j, 0, i) {
                if (j) {
                    f[i][j] = min(f[i - 1][j] + 1. * z[i].a / (_ + 1), f[i - 1][j - 1] + z[i].b / j);
                } else {
                    f[i][j] = f[i - 1][j] + 1. * z[i].a / (_ + 1);
                }
                if (j == _) {
                    mi = min(mi, f[i][j] + suf[i + 1][k - i] / (j + 1));
                }
            }
        }
    }
    double tt = min(mi, suf[1][k]);
    printf("%.23lf\n", tt);
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 4ms
memory: 75088kb

input:

1
1
729 -1

output:

0.00000000000000000000000

result:

wrong answer read 0.000000000 but expected 729.000000000, error = 729.000000000

Subtask #2:

score: 0
Wrong Answer

Test #11:

score: 0
Wrong Answer
time: 11ms
memory: 76136kb

input:

1
1
791 791

output:

0.00000000000000000000000

result:

wrong answer read 0.000000000 but expected 791.000000000, error = 791.000000000

Subtask #3:

score: 0
Wrong Answer

Test #21:

score: 0
Wrong Answer
time: 7ms
memory: 74940kb

input:

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

output:

0.00000000000000000000000

result:

wrong answer read 0.000000000 but expected 51.000000000, error = 51.000000000

Subtask #4:

score: 0
Wrong Answer

Test #36:

score: 0
Wrong Answer
time: 4ms
memory: 74836kb

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:

40.00000000000000000000000

result:

wrong answer read 40.000000000 but expected 112.000000000, error = 72.000000000

Subtask #5:

score: 0
Wrong Answer

Test #61:

score: 0
Wrong Answer
time: 11ms
memory: 75692kb

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:

284.00000000000000000000000

result:

wrong answer read 284.000000000 but expected 324.333333333, error = 40.333333333

Subtask #6:

score: 0
Wrong Answer

Test #81:

score: 0
Wrong Answer
time: 74ms
memory: 79508kb

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:

1585.59505560585830608033575

result:

wrong answer read 1585.595055606 but expected 1767.197500797, error = 181.602445191

Subtask #7:

score: 0
Wrong Answer

Test #88:

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

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:

292.83333333333337122894591

result:

wrong answer read 292.833333333 but expected 368.129761905, error = 75.296428571