/**
____ ____ ____ ____ ____ ____
||l |||e |||i |||n |||a |||d ||
||__|||__|||__|||__|||__|||__||
|/__\|/__\|/__\|/__\|/__\|/__\|
**/
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
typedef long long ll;
void speed()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
}
const int maxn = 510, smalln = 110;
struct city
{
int a, b, idx;
}c[maxn], ct[maxn];
int n, k, used[maxn];
bool cmpa(city c1, city c2)
{
return c1.a < c2.a;
}
bool cmpb(city c1, city c2)
{
if (c1.b != -1 && c2.b != -1)
return c1.b < c2.b;
if (c1.b != -1)
return true;
if (c2.b != -1)
return false;
return c1.idx < c2.idx;
}
double dp[smalln][smalln][smalln];
/// dp[i][j][f] - smallest time up to the i-th city using j votes and f collaborators
void solve()
{
cin >> n >> k;
int col = 0;
for (int i = 1; i <= n; i ++)
{
cin >> c[i].a >> c[i].b;
if (c[i].b != -1)
col ++;
c[i].idx = i;
ct[i] = c[i];
}
sort(c + 1, c + n + 1, cmpb);
double ans = 1e18;
for (int goal = 0; goal <= min(k, col); goal ++)
{
for (int i = 0; i <= n; i ++)
for (int j = 0; j <= k; j ++)
for (int f = 0; f <= goal; f ++)
dp[i][j][f] = 1e18;
dp[0][0][0] = 0.0;
for (int i = 1; i <= n; i ++)
for (int j = 0; j <= k; j ++)
for (int f = 0; f <= goal; f ++)
{
dp[i][j][f] = dp[i - 1][j][f];
if (j >= 1)
{
dp[i][j][f] = min(dp[i][j][f], dp[i - 1][j - 1][f] + c[i].a / (double)(goal + 1.0));
}
if (f >= 1 && c[i].b != -1 && j >= 1)
{
dp[i][j][f] = min(dp[i][j][f], dp[i - 1][j - 1][f - 1] + c[i].b / (double)(f));
}
}
/**cout << "--------- " << goal << " -------------------" << endl;
for (int i = 1; i <= n; i ++)
for (int j = 0; j <= k; j ++)
for (int f = 0; f <= goal; f ++)
cout << i << " " << j << " " << f << " " << dp[i][j][f] << endl;*/
ans = min(ans, dp[n][k][goal]);
}
printf("%0.6f\n", ans);
}
int main()
{
solve();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Runtime error |
9 ms |
10976 KB |
Execution killed with signal 11 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Runtime error |
9 ms |
10976 KB |
Execution killed with signal 11 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
0 ms |
340 KB |
Output is correct |
8 |
Correct |
0 ms |
340 KB |
Output is correct |
9 |
Correct |
0 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
0 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
0 ms |
340 KB |
Output is correct |
8 |
Correct |
0 ms |
340 KB |
Output is correct |
9 |
Correct |
0 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
0 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
1 ms |
468 KB |
Output is correct |
18 |
Correct |
1 ms |
560 KB |
Output is correct |
19 |
Correct |
1 ms |
568 KB |
Output is correct |
20 |
Correct |
1 ms |
596 KB |
Output is correct |
21 |
Correct |
1 ms |
596 KB |
Output is correct |
22 |
Correct |
1 ms |
568 KB |
Output is correct |
23 |
Correct |
1 ms |
568 KB |
Output is correct |
24 |
Correct |
1 ms |
596 KB |
Output is correct |
25 |
Correct |
1 ms |
724 KB |
Output is correct |
26 |
Correct |
1 ms |
692 KB |
Output is correct |
27 |
Correct |
1 ms |
596 KB |
Output is correct |
28 |
Correct |
1 ms |
596 KB |
Output is correct |
29 |
Correct |
1 ms |
596 KB |
Output is correct |
30 |
Correct |
1 ms |
568 KB |
Output is correct |
31 |
Correct |
1 ms |
572 KB |
Output is correct |
32 |
Correct |
1 ms |
596 KB |
Output is correct |
33 |
Correct |
1 ms |
596 KB |
Output is correct |
34 |
Correct |
1 ms |
596 KB |
Output is correct |
35 |
Correct |
1 ms |
596 KB |
Output is correct |
36 |
Correct |
1 ms |
596 KB |
Output is correct |
37 |
Correct |
1 ms |
568 KB |
Output is correct |
38 |
Correct |
1 ms |
564 KB |
Output is correct |
39 |
Correct |
1 ms |
596 KB |
Output is correct |
40 |
Correct |
1 ms |
596 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
0 ms |
340 KB |
Output is correct |
8 |
Correct |
0 ms |
340 KB |
Output is correct |
9 |
Correct |
0 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
0 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
1 ms |
468 KB |
Output is correct |
18 |
Correct |
1 ms |
560 KB |
Output is correct |
19 |
Correct |
1 ms |
568 KB |
Output is correct |
20 |
Correct |
1 ms |
596 KB |
Output is correct |
21 |
Correct |
1 ms |
596 KB |
Output is correct |
22 |
Correct |
1 ms |
568 KB |
Output is correct |
23 |
Correct |
1 ms |
568 KB |
Output is correct |
24 |
Correct |
1 ms |
596 KB |
Output is correct |
25 |
Correct |
1 ms |
724 KB |
Output is correct |
26 |
Correct |
1 ms |
692 KB |
Output is correct |
27 |
Correct |
1 ms |
596 KB |
Output is correct |
28 |
Correct |
1 ms |
596 KB |
Output is correct |
29 |
Correct |
1 ms |
596 KB |
Output is correct |
30 |
Correct |
1 ms |
568 KB |
Output is correct |
31 |
Correct |
1 ms |
572 KB |
Output is correct |
32 |
Correct |
1 ms |
596 KB |
Output is correct |
33 |
Correct |
1 ms |
596 KB |
Output is correct |
34 |
Correct |
1 ms |
596 KB |
Output is correct |
35 |
Correct |
1 ms |
596 KB |
Output is correct |
36 |
Correct |
1 ms |
596 KB |
Output is correct |
37 |
Correct |
1 ms |
568 KB |
Output is correct |
38 |
Correct |
1 ms |
564 KB |
Output is correct |
39 |
Correct |
1 ms |
596 KB |
Output is correct |
40 |
Correct |
1 ms |
596 KB |
Output is correct |
41 |
Correct |
2 ms |
2004 KB |
Output is correct |
42 |
Correct |
2 ms |
1976 KB |
Output is correct |
43 |
Correct |
8 ms |
3360 KB |
Output is correct |
44 |
Correct |
9 ms |
3284 KB |
Output is correct |
45 |
Correct |
37 ms |
5100 KB |
Output is correct |
46 |
Correct |
30 ms |
5092 KB |
Output is correct |
47 |
Correct |
69 ms |
6356 KB |
Output is correct |
48 |
Correct |
67 ms |
6408 KB |
Output is correct |
49 |
Correct |
134 ms |
7756 KB |
Output is correct |
50 |
Correct |
122 ms |
7688 KB |
Output is correct |
51 |
Correct |
263 ms |
9476 KB |
Output is correct |
52 |
Correct |
177 ms |
9448 KB |
Output is correct |
53 |
Correct |
78 ms |
6392 KB |
Output is correct |
54 |
Correct |
78 ms |
6408 KB |
Output is correct |
55 |
Correct |
68 ms |
6404 KB |
Output is correct |
56 |
Correct |
72 ms |
6392 KB |
Output is correct |
57 |
Correct |
66 ms |
6408 KB |
Output is correct |
58 |
Correct |
68 ms |
6480 KB |
Output is correct |
59 |
Correct |
74 ms |
6396 KB |
Output is correct |
60 |
Correct |
75 ms |
6408 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
13 ms |
21460 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Runtime error |
9 ms |
10976 KB |
Execution killed with signal 11 |
6 |
Halted |
0 ms |
0 KB |
- |