# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
806593 | 2023-08-04T08:13:23 Z | vjudge1 | Let's Win the Election (JOI22_ho_t3) | C++17 | 479 ms | 18524 KB |
#include <bits/stdc++.h> using namespace std; #define TL ios::sync_with_stdio(0),cin.tie(0),cout.tie(0); #define rall(s) s.rbegin(),s.rend() #define all(s) s.begin(),s.end() #define pb push_back #define fi first #define se second #define ll long long #define ld long double #define YES cout<<"YES\n" #define Yes cout<<"Yes\n" #define yes cout<<"yes\n" #define NO cout<<"NO\n" #define No cout<<"No\n" #define no cout<<"no\n" const int N = 500 + 9 , mod = 1e9 + 7; ll d[N] = {} , a[N] = {}, b[N] , c[N]; ld dp[N][N]; ll sum[N][N]; multiset<pair<int,int>>st[N][N]; void del(int i , int j , int x , int y){ sum[i][j] -= x; st[i][j].erase(st[i][j].find({x , y})); } void solve(){ ll q , i , j , m ,n, z ,s = 0 , f , l , r , k , x , y , mn = 1e18 , mx = 0; cin>>n>>k; vector<pair<ll,ll>>v, v1; multiset<ll>st; v.pb({-5 , -5}); for(i = 1; i <= n; i++){ cin>>a[i]>>b[i]; if(b[i] == -1) b[i] = 1e13; v1.pb({a[i] , b[i]}); v.pb({b[i] , a[i]}); st.insert(a[i]); } sort(all(v)); sort(all(v1)); mn = 0; for(i = 0; i < k; i++) mn += v1[i].fi; sum[0][0] = 0; j = 1; for(auto it : st) sum[0][j] = sum[0][j - 1] + it ,j++; for(i = 1; i <= n; i++){ st.erase(st.find(v[i].se)); sum[i][0] = 0; j = 1; for(auto it : st) sum[i][j] = sum[i][j - 1] + it ,j++; } //cout<<mn<<"\n"; ld ans = mn; for(x = 1; x <= k; x++){ for(i = 1; i <= x; i++) dp[0][i] = 1e18; for(i = 1; i <= k; i++){ for(j = 0; j <= x; j++){ if(j == 0){ dp[i][j] = dp[i - 1][j] + v[i].se / (ld) (x + 1); continue; } dp[i][j] = dp[i - 1][j] + v[i].se / (ld) (x + 1); dp[i][j] = min(dp[i][j] , dp[i - 1][j - 1] + v[i].fi / (ld) (j)); } ans = min(ans , dp[i][x] + (sum[i][k - i]) / (ld) (x + 1)); } } cout<<fixed<<setprecision(12)<<ans<<"\n"; } int main(){ TL; /* #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif */ int t = 1; //cin>>t; while(t--) { solve(); } } // Author : حسن
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 12488 KB | Output is correct |
2 | Correct | 6 ms | 12496 KB | Output is correct |
3 | Correct | 6 ms | 12436 KB | Output is correct |
4 | Correct | 6 ms | 12492 KB | Output is correct |
5 | Correct | 10 ms | 14676 KB | Output is correct |
6 | Correct | 14 ms | 15188 KB | Output is correct |
7 | Correct | 60 ms | 16516 KB | Output is correct |
8 | Correct | 183 ms | 17560 KB | Output is correct |
9 | Correct | 425 ms | 18520 KB | Output is correct |
10 | Correct | 167 ms | 17328 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 12488 KB | Output is correct |
2 | Correct | 6 ms | 12496 KB | Output is correct |
3 | Correct | 6 ms | 12436 KB | Output is correct |
4 | Correct | 6 ms | 12492 KB | Output is correct |
5 | Correct | 10 ms | 14676 KB | Output is correct |
6 | Correct | 14 ms | 15188 KB | Output is correct |
7 | Correct | 60 ms | 16516 KB | Output is correct |
8 | Correct | 183 ms | 17560 KB | Output is correct |
9 | Correct | 425 ms | 18520 KB | Output is correct |
10 | Correct | 167 ms | 17328 KB | Output is correct |
11 | Correct | 6 ms | 12496 KB | Output is correct |
12 | Correct | 22 ms | 15428 KB | Output is correct |
13 | Correct | 19 ms | 15472 KB | Output is correct |
14 | Correct | 20 ms | 15472 KB | Output is correct |
15 | Correct | 150 ms | 17224 KB | Output is correct |
16 | Correct | 155 ms | 17300 KB | Output is correct |
17 | Correct | 150 ms | 17224 KB | Output is correct |
18 | Correct | 428 ms | 18520 KB | Output is correct |
19 | Correct | 427 ms | 18520 KB | Output is correct |
20 | Correct | 445 ms | 18516 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 12500 KB | Output is correct |
2 | Correct | 6 ms | 12544 KB | Output is correct |
3 | Correct | 6 ms | 12476 KB | Output is correct |
4 | Correct | 5 ms | 12500 KB | Output is correct |
5 | Correct | 5 ms | 12500 KB | Output is correct |
6 | Correct | 6 ms | 12496 KB | Output is correct |
7 | Correct | 7 ms | 12612 KB | Output is correct |
8 | Correct | 7 ms | 12500 KB | Output is correct |
9 | Correct | 7 ms | 12544 KB | Output is correct |
10 | Correct | 6 ms | 12500 KB | Output is correct |
11 | Correct | 7 ms | 12500 KB | Output is correct |
12 | Correct | 7 ms | 12500 KB | Output is correct |
13 | Correct | 6 ms | 12552 KB | Output is correct |
14 | Correct | 7 ms | 12496 KB | Output is correct |
15 | Correct | 6 ms | 12568 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 12500 KB | Output is correct |
2 | Correct | 6 ms | 12544 KB | Output is correct |
3 | Correct | 6 ms | 12476 KB | Output is correct |
4 | Correct | 5 ms | 12500 KB | Output is correct |
5 | Correct | 5 ms | 12500 KB | Output is correct |
6 | Correct | 6 ms | 12496 KB | Output is correct |
7 | Correct | 7 ms | 12612 KB | Output is correct |
8 | Correct | 7 ms | 12500 KB | Output is correct |
9 | Correct | 7 ms | 12544 KB | Output is correct |
10 | Correct | 6 ms | 12500 KB | Output is correct |
11 | Correct | 7 ms | 12500 KB | Output is correct |
12 | Correct | 7 ms | 12500 KB | Output is correct |
13 | Correct | 6 ms | 12552 KB | Output is correct |
14 | Correct | 7 ms | 12496 KB | Output is correct |
15 | Correct | 6 ms | 12568 KB | Output is correct |
16 | Correct | 6 ms | 12500 KB | Output is correct |
17 | Correct | 6 ms | 12624 KB | Output is correct |
18 | Correct | 5 ms | 12628 KB | Output is correct |
19 | Correct | 6 ms | 12628 KB | Output is correct |
20 | Correct | 6 ms | 12628 KB | Output is correct |
21 | Correct | 6 ms | 12628 KB | Output is correct |
22 | Correct | 5 ms | 12624 KB | Output is correct |
23 | Correct | 7 ms | 12624 KB | Output is correct |
24 | Correct | 6 ms | 12628 KB | Output is correct |
25 | Correct | 6 ms | 12628 KB | Output is correct |
26 | Correct | 7 ms | 12656 KB | Output is correct |
27 | Correct | 6 ms | 12624 KB | Output is correct |
28 | Correct | 6 ms | 12628 KB | Output is correct |
29 | Correct | 6 ms | 12628 KB | Output is correct |
30 | Correct | 5 ms | 12552 KB | Output is correct |
31 | Correct | 6 ms | 12628 KB | Output is correct |
32 | Correct | 6 ms | 12592 KB | Output is correct |
33 | Correct | 6 ms | 12524 KB | Output is correct |
34 | Correct | 6 ms | 12628 KB | Output is correct |
35 | Correct | 6 ms | 12628 KB | Output is correct |
36 | Correct | 6 ms | 12628 KB | Output is correct |
37 | Correct | 5 ms | 12624 KB | Output is correct |
38 | Correct | 6 ms | 12620 KB | Output is correct |
39 | Correct | 6 ms | 12624 KB | Output is correct |
40 | Correct | 6 ms | 12628 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 12500 KB | Output is correct |
2 | Correct | 6 ms | 12544 KB | Output is correct |
3 | Correct | 6 ms | 12476 KB | Output is correct |
4 | Correct | 5 ms | 12500 KB | Output is correct |
5 | Correct | 5 ms | 12500 KB | Output is correct |
6 | Correct | 6 ms | 12496 KB | Output is correct |
7 | Correct | 7 ms | 12612 KB | Output is correct |
8 | Correct | 7 ms | 12500 KB | Output is correct |
9 | Correct | 7 ms | 12544 KB | Output is correct |
10 | Correct | 6 ms | 12500 KB | Output is correct |
11 | Correct | 7 ms | 12500 KB | Output is correct |
12 | Correct | 7 ms | 12500 KB | Output is correct |
13 | Correct | 6 ms | 12552 KB | Output is correct |
14 | Correct | 7 ms | 12496 KB | Output is correct |
15 | Correct | 6 ms | 12568 KB | Output is correct |
16 | Correct | 6 ms | 12500 KB | Output is correct |
17 | Correct | 6 ms | 12624 KB | Output is correct |
18 | Correct | 5 ms | 12628 KB | Output is correct |
19 | Correct | 6 ms | 12628 KB | Output is correct |
20 | Correct | 6 ms | 12628 KB | Output is correct |
21 | Correct | 6 ms | 12628 KB | Output is correct |
22 | Correct | 5 ms | 12624 KB | Output is correct |
23 | Correct | 7 ms | 12624 KB | Output is correct |
24 | Correct | 6 ms | 12628 KB | Output is correct |
25 | Correct | 6 ms | 12628 KB | Output is correct |
26 | Correct | 7 ms | 12656 KB | Output is correct |
27 | Correct | 6 ms | 12624 KB | Output is correct |
28 | Correct | 6 ms | 12628 KB | Output is correct |
29 | Correct | 6 ms | 12628 KB | Output is correct |
30 | Correct | 5 ms | 12552 KB | Output is correct |
31 | Correct | 6 ms | 12628 KB | Output is correct |
32 | Correct | 6 ms | 12592 KB | Output is correct |
33 | Correct | 6 ms | 12524 KB | Output is correct |
34 | Correct | 6 ms | 12628 KB | Output is correct |
35 | Correct | 6 ms | 12628 KB | Output is correct |
36 | Correct | 6 ms | 12628 KB | Output is correct |
37 | Correct | 5 ms | 12624 KB | Output is correct |
38 | Correct | 6 ms | 12620 KB | Output is correct |
39 | Correct | 6 ms | 12624 KB | Output is correct |
40 | Correct | 6 ms | 12628 KB | Output is correct |
41 | Correct | 6 ms | 12884 KB | Output is correct |
42 | Correct | 5 ms | 12884 KB | Output is correct |
43 | Correct | 6 ms | 13012 KB | Output is correct |
44 | Correct | 6 ms | 13016 KB | Output is correct |
45 | Correct | 7 ms | 13072 KB | Output is correct |
46 | Correct | 6 ms | 13140 KB | Output is correct |
47 | Correct | 7 ms | 13268 KB | Output is correct |
48 | Correct | 7 ms | 13140 KB | Output is correct |
49 | Correct | 10 ms | 13264 KB | Output is correct |
50 | Correct | 8 ms | 13268 KB | Output is correct |
51 | Correct | 10 ms | 13452 KB | Output is correct |
52 | Correct | 10 ms | 13392 KB | Output is correct |
53 | Correct | 7 ms | 13260 KB | Output is correct |
54 | Correct | 7 ms | 13268 KB | Output is correct |
55 | Correct | 8 ms | 13172 KB | Output is correct |
56 | Correct | 7 ms | 13268 KB | Output is correct |
57 | Correct | 7 ms | 13216 KB | Output is correct |
58 | Correct | 7 ms | 13260 KB | Output is correct |
59 | Correct | 7 ms | 13264 KB | Output is correct |
60 | Correct | 10 ms | 13240 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 479 ms | 18520 KB | Output is correct |
2 | Correct | 434 ms | 18520 KB | Output is correct |
3 | Correct | 420 ms | 18524 KB | Output is correct |
4 | Correct | 431 ms | 18512 KB | Output is correct |
5 | Correct | 427 ms | 18520 KB | Output is correct |
6 | Correct | 423 ms | 18520 KB | Output is correct |
7 | Correct | 428 ms | 18468 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 12488 KB | Output is correct |
2 | Correct | 6 ms | 12496 KB | Output is correct |
3 | Correct | 6 ms | 12436 KB | Output is correct |
4 | Correct | 6 ms | 12492 KB | Output is correct |
5 | Correct | 10 ms | 14676 KB | Output is correct |
6 | Correct | 14 ms | 15188 KB | Output is correct |
7 | Correct | 60 ms | 16516 KB | Output is correct |
8 | Correct | 183 ms | 17560 KB | Output is correct |
9 | Correct | 425 ms | 18520 KB | Output is correct |
10 | Correct | 167 ms | 17328 KB | Output is correct |
11 | Correct | 6 ms | 12496 KB | Output is correct |
12 | Correct | 22 ms | 15428 KB | Output is correct |
13 | Correct | 19 ms | 15472 KB | Output is correct |
14 | Correct | 20 ms | 15472 KB | Output is correct |
15 | Correct | 150 ms | 17224 KB | Output is correct |
16 | Correct | 155 ms | 17300 KB | Output is correct |
17 | Correct | 150 ms | 17224 KB | Output is correct |
18 | Correct | 428 ms | 18520 KB | Output is correct |
19 | Correct | 427 ms | 18520 KB | Output is correct |
20 | Correct | 445 ms | 18516 KB | Output is correct |
21 | Correct | 5 ms | 12500 KB | Output is correct |
22 | Correct | 6 ms | 12544 KB | Output is correct |
23 | Correct | 6 ms | 12476 KB | Output is correct |
24 | Correct | 5 ms | 12500 KB | Output is correct |
25 | Correct | 5 ms | 12500 KB | Output is correct |
26 | Correct | 6 ms | 12496 KB | Output is correct |
27 | Correct | 7 ms | 12612 KB | Output is correct |
28 | Correct | 7 ms | 12500 KB | Output is correct |
29 | Correct | 7 ms | 12544 KB | Output is correct |
30 | Correct | 6 ms | 12500 KB | Output is correct |
31 | Correct | 7 ms | 12500 KB | Output is correct |
32 | Correct | 7 ms | 12500 KB | Output is correct |
33 | Correct | 6 ms | 12552 KB | Output is correct |
34 | Correct | 7 ms | 12496 KB | Output is correct |
35 | Correct | 6 ms | 12568 KB | Output is correct |
36 | Correct | 6 ms | 12500 KB | Output is correct |
37 | Correct | 6 ms | 12624 KB | Output is correct |
38 | Correct | 5 ms | 12628 KB | Output is correct |
39 | Correct | 6 ms | 12628 KB | Output is correct |
40 | Correct | 6 ms | 12628 KB | Output is correct |
41 | Correct | 6 ms | 12628 KB | Output is correct |
42 | Correct | 5 ms | 12624 KB | Output is correct |
43 | Correct | 7 ms | 12624 KB | Output is correct |
44 | Correct | 6 ms | 12628 KB | Output is correct |
45 | Correct | 6 ms | 12628 KB | Output is correct |
46 | Correct | 7 ms | 12656 KB | Output is correct |
47 | Correct | 6 ms | 12624 KB | Output is correct |
48 | Correct | 6 ms | 12628 KB | Output is correct |
49 | Correct | 6 ms | 12628 KB | Output is correct |
50 | Correct | 5 ms | 12552 KB | Output is correct |
51 | Correct | 6 ms | 12628 KB | Output is correct |
52 | Correct | 6 ms | 12592 KB | Output is correct |
53 | Correct | 6 ms | 12524 KB | Output is correct |
54 | Correct | 6 ms | 12628 KB | Output is correct |
55 | Correct | 6 ms | 12628 KB | Output is correct |
56 | Correct | 6 ms | 12628 KB | Output is correct |
57 | Correct | 5 ms | 12624 KB | Output is correct |
58 | Correct | 6 ms | 12620 KB | Output is correct |
59 | Correct | 6 ms | 12624 KB | Output is correct |
60 | Correct | 6 ms | 12628 KB | Output is correct |
61 | Correct | 6 ms | 12884 KB | Output is correct |
62 | Correct | 5 ms | 12884 KB | Output is correct |
63 | Correct | 6 ms | 13012 KB | Output is correct |
64 | Correct | 6 ms | 13016 KB | Output is correct |
65 | Correct | 7 ms | 13072 KB | Output is correct |
66 | Correct | 6 ms | 13140 KB | Output is correct |
67 | Correct | 7 ms | 13268 KB | Output is correct |
68 | Correct | 7 ms | 13140 KB | Output is correct |
69 | Correct | 10 ms | 13264 KB | Output is correct |
70 | Correct | 8 ms | 13268 KB | Output is correct |
71 | Correct | 10 ms | 13452 KB | Output is correct |
72 | Correct | 10 ms | 13392 KB | Output is correct |
73 | Correct | 7 ms | 13260 KB | Output is correct |
74 | Correct | 7 ms | 13268 KB | Output is correct |
75 | Correct | 8 ms | 13172 KB | Output is correct |
76 | Correct | 7 ms | 13268 KB | Output is correct |
77 | Correct | 7 ms | 13216 KB | Output is correct |
78 | Correct | 7 ms | 13260 KB | Output is correct |
79 | Correct | 7 ms | 13264 KB | Output is correct |
80 | Correct | 10 ms | 13240 KB | Output is correct |
81 | Correct | 479 ms | 18520 KB | Output is correct |
82 | Correct | 434 ms | 18520 KB | Output is correct |
83 | Correct | 420 ms | 18524 KB | Output is correct |
84 | Correct | 431 ms | 18512 KB | Output is correct |
85 | Correct | 427 ms | 18520 KB | Output is correct |
86 | Correct | 423 ms | 18520 KB | Output is correct |
87 | Correct | 428 ms | 18468 KB | Output is correct |
88 | Correct | 7 ms | 14676 KB | Output is correct |
89 | Correct | 7 ms | 14676 KB | Output is correct |
90 | Correct | 15 ms | 15204 KB | Output is correct |
91 | Correct | 14 ms | 15164 KB | Output is correct |
92 | Correct | 65 ms | 16520 KB | Output is correct |
93 | Correct | 61 ms | 16436 KB | Output is correct |
94 | Correct | 184 ms | 17524 KB | Output is correct |
95 | Correct | 185 ms | 17456 KB | Output is correct |
96 | Correct | 313 ms | 18120 KB | Output is correct |
97 | Correct | 327 ms | 18080 KB | Output is correct |
98 | Correct | 174 ms | 17276 KB | Output is correct |
99 | Correct | 149 ms | 17220 KB | Output is correct |
100 | Correct | 149 ms | 17204 KB | Output is correct |
101 | Correct | 158 ms | 17328 KB | Output is correct |
102 | Correct | 149 ms | 17328 KB | Output is correct |
103 | Correct | 157 ms | 17300 KB | Output is correct |
104 | Correct | 150 ms | 17228 KB | Output is correct |
105 | Correct | 161 ms | 17324 KB | Output is correct |