답안 #965702

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
965702 2024-04-19T05:45:34 Z 12345678 Let's Win the Election (JOI22_ho_t3) C++17
100 / 100
155 ms 4444 KB
#include <bits/stdc++.h>

using namespace std;

const int nx=505;

int n, m;
vector<pair<int, int>> v(nx);
double dp[nx][nx], sm[nx][nx], ans;

int32_t main()
{
    cin.tie(NULL)->sync_with_stdio(false);
    cin>>n>>m;
    v.resize(n);
    for (int i=0; i<n; i++) 
    {
        cin>>v[i].second>>v[i].first;
        if (v[i].first==-1) v[i].first=1e9;
    }
    sort(v.begin(), v.end());
    for (int i=1; i<=m; i++) sm[n+1][i]=1e9;
    for (int i=n;i>=1; i--) for (int j=1; j<=m; j++) sm[i][j]=min(sm[i+1][j], sm[i+1][j-1]+v[i-1].second); //cout<<"sm "<<i<<' '<<j<<' '<<sm[i][j]<<'\n';
    ans=sm[1][m];
    for (int i=1; i<=m; i++)
    {
        for (int j=0; j<=m; j++) for (int k=0; k<=i; k++) dp[j][k]=1e9;
        dp[0][1]=0;
        for (int j=1; j<=m; j++)
        {
            for (int k=1; k<=i; k++)
            {
                dp[j][k]=dp[j-1][k]+(double)v[j-1].second/i;
                if (k>1&&v[j-1].first<=1000) dp[j][k]=min(dp[j][k], dp[j-1][k-1]+((double)v[j-1].first)/(k-1));
                //cout<<"debug "<<i<<' '<<j<<' '<<k<<' '<<dp[j][k]<<'\n';
            }
            ans=min(ans, dp[j][i]+sm[j+1][m-j]/i);
            //cout<<i<<' '<<j<<' '<<dp[j][i]+sm[j+1][m-j]/i<<'\n';
        }
    }
    cout<<fixed<<setprecision(12)<<ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2652 KB Output is correct
6 Correct 3 ms 2908 KB Output is correct
7 Correct 14 ms 3420 KB Output is correct
8 Correct 46 ms 3932 KB Output is correct
9 Correct 106 ms 4184 KB Output is correct
10 Correct 36 ms 3672 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2652 KB Output is correct
6 Correct 3 ms 2908 KB Output is correct
7 Correct 14 ms 3420 KB Output is correct
8 Correct 46 ms 3932 KB Output is correct
9 Correct 106 ms 4184 KB Output is correct
10 Correct 36 ms 3672 KB Output is correct
11 Correct 1 ms 2392 KB Output is correct
12 Correct 5 ms 2904 KB Output is correct
13 Correct 5 ms 2904 KB Output is correct
14 Correct 4 ms 2904 KB Output is correct
15 Correct 56 ms 3676 KB Output is correct
16 Correct 48 ms 3672 KB Output is correct
17 Correct 40 ms 3672 KB Output is correct
18 Correct 155 ms 4420 KB Output is correct
19 Correct 148 ms 4188 KB Output is correct
20 Correct 110 ms 4440 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 2 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2392 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 2520 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 2 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2392 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 2520 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2652 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 1 ms 2392 KB Output is correct
20 Correct 1 ms 2396 KB Output is correct
21 Correct 1 ms 2512 KB Output is correct
22 Correct 1 ms 2396 KB Output is correct
23 Correct 1 ms 2396 KB Output is correct
24 Correct 1 ms 2396 KB Output is correct
25 Correct 1 ms 2396 KB Output is correct
26 Correct 1 ms 2392 KB Output is correct
27 Correct 1 ms 2396 KB Output is correct
28 Correct 1 ms 2396 KB Output is correct
29 Correct 1 ms 2396 KB Output is correct
30 Correct 1 ms 2392 KB Output is correct
31 Correct 1 ms 2396 KB Output is correct
32 Correct 1 ms 2396 KB Output is correct
33 Correct 1 ms 2396 KB Output is correct
34 Correct 1 ms 2392 KB Output is correct
35 Correct 1 ms 2392 KB Output is correct
36 Correct 1 ms 2396 KB Output is correct
37 Correct 1 ms 2600 KB Output is correct
38 Correct 1 ms 2396 KB Output is correct
39 Correct 1 ms 2396 KB Output is correct
40 Correct 1 ms 2396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 2 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2392 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 2520 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2652 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 1 ms 2392 KB Output is correct
20 Correct 1 ms 2396 KB Output is correct
21 Correct 1 ms 2512 KB Output is correct
22 Correct 1 ms 2396 KB Output is correct
23 Correct 1 ms 2396 KB Output is correct
24 Correct 1 ms 2396 KB Output is correct
25 Correct 1 ms 2396 KB Output is correct
26 Correct 1 ms 2392 KB Output is correct
27 Correct 1 ms 2396 KB Output is correct
28 Correct 1 ms 2396 KB Output is correct
29 Correct 1 ms 2396 KB Output is correct
30 Correct 1 ms 2392 KB Output is correct
31 Correct 1 ms 2396 KB Output is correct
32 Correct 1 ms 2396 KB Output is correct
33 Correct 1 ms 2396 KB Output is correct
34 Correct 1 ms 2392 KB Output is correct
35 Correct 1 ms 2392 KB Output is correct
36 Correct 1 ms 2396 KB Output is correct
37 Correct 1 ms 2600 KB Output is correct
38 Correct 1 ms 2396 KB Output is correct
39 Correct 1 ms 2396 KB Output is correct
40 Correct 1 ms 2396 KB Output is correct
41 Correct 1 ms 2648 KB Output is correct
42 Correct 1 ms 2652 KB Output is correct
43 Correct 1 ms 2652 KB Output is correct
44 Correct 1 ms 2652 KB Output is correct
45 Correct 1 ms 2512 KB Output is correct
46 Correct 1 ms 2652 KB Output is correct
47 Correct 1 ms 2652 KB Output is correct
48 Correct 1 ms 2652 KB Output is correct
49 Correct 1 ms 2652 KB Output is correct
50 Correct 1 ms 2652 KB Output is correct
51 Correct 2 ms 2652 KB Output is correct
52 Correct 2 ms 2652 KB Output is correct
53 Correct 1 ms 2648 KB Output is correct
54 Correct 1 ms 2652 KB Output is correct
55 Correct 1 ms 2652 KB Output is correct
56 Correct 1 ms 2652 KB Output is correct
57 Correct 1 ms 2652 KB Output is correct
58 Correct 1 ms 2660 KB Output is correct
59 Correct 1 ms 2652 KB Output is correct
60 Correct 1 ms 2652 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 142 ms 4420 KB Output is correct
2 Correct 144 ms 4420 KB Output is correct
3 Correct 144 ms 4420 KB Output is correct
4 Correct 138 ms 4184 KB Output is correct
5 Correct 143 ms 4444 KB Output is correct
6 Correct 139 ms 4440 KB Output is correct
7 Correct 139 ms 4420 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2652 KB Output is correct
6 Correct 3 ms 2908 KB Output is correct
7 Correct 14 ms 3420 KB Output is correct
8 Correct 46 ms 3932 KB Output is correct
9 Correct 106 ms 4184 KB Output is correct
10 Correct 36 ms 3672 KB Output is correct
11 Correct 1 ms 2392 KB Output is correct
12 Correct 5 ms 2904 KB Output is correct
13 Correct 5 ms 2904 KB Output is correct
14 Correct 4 ms 2904 KB Output is correct
15 Correct 56 ms 3676 KB Output is correct
16 Correct 48 ms 3672 KB Output is correct
17 Correct 40 ms 3672 KB Output is correct
18 Correct 155 ms 4420 KB Output is correct
19 Correct 148 ms 4188 KB Output is correct
20 Correct 110 ms 4440 KB Output is correct
21 Correct 1 ms 2392 KB Output is correct
22 Correct 1 ms 2396 KB Output is correct
23 Correct 2 ms 2396 KB Output is correct
24 Correct 1 ms 2396 KB Output is correct
25 Correct 1 ms 2392 KB Output is correct
26 Correct 1 ms 2396 KB Output is correct
27 Correct 1 ms 2396 KB Output is correct
28 Correct 1 ms 2396 KB Output is correct
29 Correct 1 ms 2396 KB Output is correct
30 Correct 1 ms 2396 KB Output is correct
31 Correct 1 ms 2396 KB Output is correct
32 Correct 1 ms 2520 KB Output is correct
33 Correct 1 ms 2396 KB Output is correct
34 Correct 1 ms 2396 KB Output is correct
35 Correct 1 ms 2396 KB Output is correct
36 Correct 1 ms 2652 KB Output is correct
37 Correct 1 ms 2396 KB Output is correct
38 Correct 1 ms 2396 KB Output is correct
39 Correct 1 ms 2392 KB Output is correct
40 Correct 1 ms 2396 KB Output is correct
41 Correct 1 ms 2512 KB Output is correct
42 Correct 1 ms 2396 KB Output is correct
43 Correct 1 ms 2396 KB Output is correct
44 Correct 1 ms 2396 KB Output is correct
45 Correct 1 ms 2396 KB Output is correct
46 Correct 1 ms 2392 KB Output is correct
47 Correct 1 ms 2396 KB Output is correct
48 Correct 1 ms 2396 KB Output is correct
49 Correct 1 ms 2396 KB Output is correct
50 Correct 1 ms 2392 KB Output is correct
51 Correct 1 ms 2396 KB Output is correct
52 Correct 1 ms 2396 KB Output is correct
53 Correct 1 ms 2396 KB Output is correct
54 Correct 1 ms 2392 KB Output is correct
55 Correct 1 ms 2392 KB Output is correct
56 Correct 1 ms 2396 KB Output is correct
57 Correct 1 ms 2600 KB Output is correct
58 Correct 1 ms 2396 KB Output is correct
59 Correct 1 ms 2396 KB Output is correct
60 Correct 1 ms 2396 KB Output is correct
61 Correct 1 ms 2648 KB Output is correct
62 Correct 1 ms 2652 KB Output is correct
63 Correct 1 ms 2652 KB Output is correct
64 Correct 1 ms 2652 KB Output is correct
65 Correct 1 ms 2512 KB Output is correct
66 Correct 1 ms 2652 KB Output is correct
67 Correct 1 ms 2652 KB Output is correct
68 Correct 1 ms 2652 KB Output is correct
69 Correct 1 ms 2652 KB Output is correct
70 Correct 1 ms 2652 KB Output is correct
71 Correct 2 ms 2652 KB Output is correct
72 Correct 2 ms 2652 KB Output is correct
73 Correct 1 ms 2648 KB Output is correct
74 Correct 1 ms 2652 KB Output is correct
75 Correct 1 ms 2652 KB Output is correct
76 Correct 1 ms 2652 KB Output is correct
77 Correct 1 ms 2652 KB Output is correct
78 Correct 1 ms 2660 KB Output is correct
79 Correct 1 ms 2652 KB Output is correct
80 Correct 1 ms 2652 KB Output is correct
81 Correct 142 ms 4420 KB Output is correct
82 Correct 144 ms 4420 KB Output is correct
83 Correct 144 ms 4420 KB Output is correct
84 Correct 138 ms 4184 KB Output is correct
85 Correct 143 ms 4444 KB Output is correct
86 Correct 139 ms 4440 KB Output is correct
87 Correct 139 ms 4420 KB Output is correct
88 Correct 1 ms 2652 KB Output is correct
89 Correct 1 ms 2652 KB Output is correct
90 Correct 3 ms 2908 KB Output is correct
91 Correct 4 ms 2908 KB Output is correct
92 Correct 22 ms 3456 KB Output is correct
93 Correct 19 ms 3416 KB Output is correct
94 Correct 60 ms 3932 KB Output is correct
95 Correct 61 ms 4180 KB Output is correct
96 Correct 106 ms 4188 KB Output is correct
97 Correct 102 ms 4188 KB Output is correct
98 Correct 50 ms 3948 KB Output is correct
99 Correct 62 ms 3672 KB Output is correct
100 Correct 49 ms 3680 KB Output is correct
101 Correct 51 ms 3676 KB Output is correct
102 Correct 49 ms 3672 KB Output is correct
103 Correct 52 ms 3848 KB Output is correct
104 Correct 62 ms 3824 KB Output is correct
105 Correct 50 ms 3672 KB Output is correct