답안 #806891

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
806891 2023-08-04T10:52:05 Z Cookie Let's Win the Election (JOI22_ho_t3) C++14
72 / 100
46 ms 3828 KB
#include<bits/stdc++.h>
#include<fstream>
#pragma GCC optimize("Ofast,O3,unroll-loops")
#pragma GCC target("avx2")
using namespace std;
//ifstream fin("FEEDING.INP");
//ofstream fout("FEEDING.OUT");
#define sz(a) (int)a.size()
#define ll long long
#define pb push_back
#define forr(i, a, b) for(int i = a; i < b; i++)
#define dorr(i, a, b) for(int i = a; i >= b; i--)
#define ld long double
#define vt vector
#include<fstream>
#define fi first
#define se second
#define pll pair<ll, ll>
#define pii pair<int, int>
const int base = 74;
const ll mod = 1e9 + 7, inf = 1e18, mxv = 1005, mxn = 2e5 + 5;
int n, k;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ld dp[505][505];
pll p[mxn + 1];
bool cmp(pll &a, pll &b){
    return(a.se < b.se);
}
ld get(int x){
    for(int i = 1; i <= n; i++){
        for(int j = 0; j <= min(i, x); j++){
            dp[i][j] = inf;
            int other = i - j;
            if(other <= k - x){
                dp[i][j] = dp[i - 1][j] + (ld)p[i].se / (other);
            }else{
                dp[i][j] = dp[i - 1][j];
            }
            other = min(other, k - x);
            if(j > 0){
                dp[i][j] = min(dp[i][j], dp[i - 1][j - 1] + (ld)p[i].fi / (k - x + 1));
                
            }
            
        }
    }
    return(dp[n][x]);
}
signed main()
{
     ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n >> k;
    for(int i = 1; i <= n; i++){
        cin >> p[i].fi >> p[i].se;
        if(p[i].se == -1)p[i].se = 1e9;
    }
    sort(p + 1, p + n + 1, cmp);
    int l = 0, r = k;
    ld ans = inf;
    while(l <= r){
        int m1 = l + (r - l) / 3, m2 = r - (r - l) / 3;
        ld val1 = get(m1), val2 = get(m2);
        if(val1 < val2){
            ans = val1; r = m2 - 1;
        }else if(val1 > val2){
            ans = val2; l = m1 + 1;
        }else{
            r = m2 - 1; l = m1 + 1;
        }
    }
    cout << fixed << setprecision(10) << ans;
    return(0);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 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 Correct 5 ms 2644 KB Output is correct
6 Correct 12 ms 3156 KB Output is correct
7 Correct 26 ms 3812 KB Output is correct
8 Correct 30 ms 3820 KB Output is correct
9 Correct 46 ms 3796 KB Output is correct
10 Correct 30 ms 3800 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 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 Correct 5 ms 2644 KB Output is correct
6 Correct 12 ms 3156 KB Output is correct
7 Correct 26 ms 3812 KB Output is correct
8 Correct 30 ms 3820 KB Output is correct
9 Correct 46 ms 3796 KB Output is correct
10 Correct 30 ms 3800 KB Output is correct
11 Incorrect 0 ms 340 KB Output isn't correct
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 1 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 1 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 1 ms 340 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
# 결과 실행 시간 메모리 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 1 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 1 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 1 ms 340 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 0 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 0 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 0 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 0 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 0 ms 340 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 1 ms 340 KB Output is correct
35 Correct 1 ms 340 KB Output is correct
36 Correct 1 ms 340 KB Output is correct
37 Correct 1 ms 340 KB Output is correct
38 Correct 0 ms 340 KB Output is correct
39 Correct 0 ms 340 KB Output is correct
40 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 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 1 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 1 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 1 ms 340 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 0 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 0 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 0 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 0 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 0 ms 340 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 1 ms 340 KB Output is correct
35 Correct 1 ms 340 KB Output is correct
36 Correct 1 ms 340 KB Output is correct
37 Correct 1 ms 340 KB Output is correct
38 Correct 0 ms 340 KB Output is correct
39 Correct 0 ms 340 KB Output is correct
40 Correct 1 ms 340 KB Output is correct
41 Correct 1 ms 724 KB Output is correct
42 Correct 1 ms 724 KB Output is correct
43 Correct 1 ms 712 KB Output is correct
44 Correct 1 ms 724 KB Output is correct
45 Correct 1 ms 724 KB Output is correct
46 Correct 1 ms 724 KB Output is correct
47 Correct 1 ms 724 KB Output is correct
48 Correct 1 ms 724 KB Output is correct
49 Correct 1 ms 724 KB Output is correct
50 Correct 1 ms 724 KB Output is correct
51 Correct 1 ms 724 KB Output is correct
52 Correct 2 ms 852 KB Output is correct
53 Correct 1 ms 724 KB Output is correct
54 Correct 1 ms 724 KB Output is correct
55 Correct 1 ms 724 KB Output is correct
56 Correct 1 ms 724 KB Output is correct
57 Correct 1 ms 724 KB Output is correct
58 Correct 1 ms 724 KB Output is correct
59 Correct 1 ms 724 KB Output is correct
60 Correct 1 ms 724 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 26 ms 3796 KB Output is correct
2 Correct 24 ms 3796 KB Output is correct
3 Correct 20 ms 3796 KB Output is correct
4 Correct 16 ms 3828 KB Output is correct
5 Correct 12 ms 3796 KB Output is correct
6 Correct 29 ms 3796 KB Output is correct
7 Correct 14 ms 3824 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 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 Correct 5 ms 2644 KB Output is correct
6 Correct 12 ms 3156 KB Output is correct
7 Correct 26 ms 3812 KB Output is correct
8 Correct 30 ms 3820 KB Output is correct
9 Correct 46 ms 3796 KB Output is correct
10 Correct 30 ms 3800 KB Output is correct
11 Incorrect 0 ms 340 KB Output isn't correct
12 Halted 0 ms 0 KB -