Submission #635290

# Submission time Handle Problem Language Result Execution time Memory
635290 2022-08-25T21:59:01 Z urosk Let's Win the Election (JOI22_ho_t3) C++14
100 / 100
159 ms 4428 KB
#define here cerr<<"===========================================\n"
#define dbg(x) cerr<<#x<<": "<<x<<endl;
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define ld double
#define ll long long
#define llinf 100000000000000000LL // 10^17
#define pb push_back
#define popb pop_back
#define fi first
#define sc second
#define endl '\n'
#define pll pair<ll,ll>
#define pld pair<ld,ld>
#define sz(a) (ll)(a.size())
#define all(a) a.begin(),a.end()
#define ceri(a,l,r) {cerr<<#a<<": ";for(ll i_ = l;i_<=r;i_++) cerr<<a[i_]<< " ";cerr<<endl;}
#define daj_mi_malo_vremena ios_base::sync_with_stdio(false);cerr.tie(0);cout.tie(0);cin.tie(0);

using namespace std;
using namespace __gnu_pbds;
/*
ll add(ll x,ll y){
    x+=y;
    if(x<0){
        x%=mod;
        x+=mod;
    }else{
        if(x>=mod) x%=mod;
    }
    return x;
}
ll mul(ll a,ll b){
	ll ans = (a*b)%mod;
	if(ans<0) ans+=mod;
	return ans;
}
typedef tree<int,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<int,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll rnd(ll l,ll r){
    return uniform_int_distribution<ll>(l,r)(rng);
}
*/
#define maxn 505
ll n,k;
ll calc[maxn][maxn];
ld dp[maxn][maxn];
pll a[maxn];
bool cmp(pll a,pll b){
    if(a.sc!=b.sc) return a.sc<b.sc;
    return a.fi>b.fi;
}
int main(){
	daj_mi_malo_vremena
	cout<<fixed<<setprecision(30);
	cerr<<fixed<<setprecision(30);
    cin >> n >> k;
    for(ll i = 1;i<=n;i++) cin >> a[i].fi >> a[i].sc;
    for(ll i = 1;i<=n;i++) if(a[i].sc==-1) a[i].sc = 2000;
    sort(a+1,a+1+n,cmp);
    for(ll i = 0;i<=n+1;i++) for(ll j = 0;j<=n+1;j++) dp[i][j] = calc[i][j] = llinf;
    calc[n+1][0] = 0;
    for(ll i = n;i>=1;i--){
        calc[i][0] = 0;
        for(ll j = 1;j<=n;j++) calc[i][j] = min(calc[i+1][j],calc[i+1][j-1]+a[i].fi);
    }
    ld ans = llinf;
    dp[0][0] = 0;
    for(ll e = 0;e<=k;e++){
        for(ll i = 1;i<=n;i++){
            dp[0][0] = 0;
            for(ll j = 0;j<=e;j++){
                dp[i][j] = dp[i-1][j] + 1.0*a[i].fi/(e+1);
                if(a[i].sc!=2000&&j) dp[i][j] = min(dp[i][j],dp[i-1][j-1]+1.0*a[i].sc/j);
            }
        }
        for(ll i = e;i<=k;i++) ans = min(ans,dp[i][e]+1.0*calc[i+1][k-i]/(e+1));
    }
    cout<<ans<<endl;
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 328 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 3 ms 4180 KB Output is correct
6 Correct 6 ms 4428 KB Output is correct
7 Correct 16 ms 4300 KB Output is correct
8 Correct 30 ms 4180 KB Output is correct
9 Correct 49 ms 4288 KB Output is correct
10 Correct 35 ms 4180 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 328 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 3 ms 4180 KB Output is correct
6 Correct 6 ms 4428 KB Output is correct
7 Correct 16 ms 4300 KB Output is correct
8 Correct 30 ms 4180 KB Output is correct
9 Correct 49 ms 4288 KB Output is correct
10 Correct 35 ms 4180 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 14 ms 4308 KB Output is correct
13 Correct 11 ms 4296 KB Output is correct
14 Correct 8 ms 4300 KB Output is correct
15 Correct 67 ms 4292 KB Output is correct
16 Correct 49 ms 4288 KB Output is correct
17 Correct 35 ms 4292 KB Output is correct
18 Correct 135 ms 4300 KB Output is correct
19 Correct 117 ms 4288 KB Output is correct
20 Correct 76 ms 4180 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 1 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 1 ms 340 KB Output is correct
9 Correct 0 ms 324 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 328 KB Output is correct
14 Correct 0 ms 332 KB Output is correct
15 Correct 0 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 1 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 1 ms 340 KB Output is correct
9 Correct 0 ms 324 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 328 KB Output is correct
14 Correct 0 ms 332 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
16 Correct 1 ms 468 KB Output is correct
17 Correct 1 ms 468 KB Output is correct
18 Correct 1 ms 468 KB Output is correct
19 Correct 0 ms 468 KB Output is correct
20 Correct 1 ms 468 KB Output is correct
21 Correct 0 ms 468 KB Output is correct
22 Correct 1 ms 468 KB Output is correct
23 Correct 1 ms 468 KB Output is correct
24 Correct 1 ms 468 KB Output is correct
25 Correct 1 ms 468 KB Output is correct
26 Correct 0 ms 452 KB Output is correct
27 Correct 1 ms 468 KB Output is correct
28 Correct 1 ms 452 KB Output is correct
29 Correct 1 ms 468 KB Output is correct
30 Correct 1 ms 452 KB Output is correct
31 Correct 1 ms 468 KB Output is correct
32 Correct 1 ms 460 KB Output is correct
33 Correct 1 ms 468 KB Output is correct
34 Correct 1 ms 468 KB Output is correct
35 Correct 1 ms 468 KB Output is correct
36 Correct 1 ms 468 KB Output is correct
37 Correct 1 ms 468 KB Output is correct
38 Correct 0 ms 468 KB Output is correct
39 Correct 1 ms 468 KB Output is correct
40 Correct 1 ms 468 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 1 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 1 ms 340 KB Output is correct
9 Correct 0 ms 324 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 328 KB Output is correct
14 Correct 0 ms 332 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
16 Correct 1 ms 468 KB Output is correct
17 Correct 1 ms 468 KB Output is correct
18 Correct 1 ms 468 KB Output is correct
19 Correct 0 ms 468 KB Output is correct
20 Correct 1 ms 468 KB Output is correct
21 Correct 0 ms 468 KB Output is correct
22 Correct 1 ms 468 KB Output is correct
23 Correct 1 ms 468 KB Output is correct
24 Correct 1 ms 468 KB Output is correct
25 Correct 1 ms 468 KB Output is correct
26 Correct 0 ms 452 KB Output is correct
27 Correct 1 ms 468 KB Output is correct
28 Correct 1 ms 452 KB Output is correct
29 Correct 1 ms 468 KB Output is correct
30 Correct 1 ms 452 KB Output is correct
31 Correct 1 ms 468 KB Output is correct
32 Correct 1 ms 460 KB Output is correct
33 Correct 1 ms 468 KB Output is correct
34 Correct 1 ms 468 KB Output is correct
35 Correct 1 ms 468 KB Output is correct
36 Correct 1 ms 468 KB Output is correct
37 Correct 1 ms 468 KB Output is correct
38 Correct 0 ms 468 KB Output is correct
39 Correct 1 ms 468 KB Output is correct
40 Correct 1 ms 468 KB Output is correct
41 Correct 1 ms 1108 KB Output is correct
42 Correct 1 ms 1108 KB Output is correct
43 Correct 1 ms 1108 KB Output is correct
44 Correct 1 ms 1108 KB Output is correct
45 Correct 1 ms 1108 KB Output is correct
46 Correct 1 ms 1108 KB Output is correct
47 Correct 1 ms 1108 KB Output is correct
48 Correct 2 ms 1108 KB Output is correct
49 Correct 2 ms 1108 KB Output is correct
50 Correct 2 ms 1092 KB Output is correct
51 Correct 2 ms 1108 KB Output is correct
52 Correct 2 ms 1108 KB Output is correct
53 Correct 1 ms 1108 KB Output is correct
54 Correct 1 ms 1108 KB Output is correct
55 Correct 2 ms 1092 KB Output is correct
56 Correct 1 ms 1108 KB Output is correct
57 Correct 1 ms 1096 KB Output is correct
58 Correct 1 ms 1108 KB Output is correct
59 Correct 1 ms 1108 KB Output is correct
60 Correct 1 ms 1108 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 131 ms 4288 KB Output is correct
2 Correct 159 ms 4288 KB Output is correct
3 Correct 130 ms 4308 KB Output is correct
4 Correct 130 ms 4284 KB Output is correct
5 Correct 132 ms 4308 KB Output is correct
6 Correct 131 ms 4180 KB Output is correct
7 Correct 157 ms 4288 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 328 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 3 ms 4180 KB Output is correct
6 Correct 6 ms 4428 KB Output is correct
7 Correct 16 ms 4300 KB Output is correct
8 Correct 30 ms 4180 KB Output is correct
9 Correct 49 ms 4288 KB Output is correct
10 Correct 35 ms 4180 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 14 ms 4308 KB Output is correct
13 Correct 11 ms 4296 KB Output is correct
14 Correct 8 ms 4300 KB Output is correct
15 Correct 67 ms 4292 KB Output is correct
16 Correct 49 ms 4288 KB Output is correct
17 Correct 35 ms 4292 KB Output is correct
18 Correct 135 ms 4300 KB Output is correct
19 Correct 117 ms 4288 KB Output is correct
20 Correct 76 ms 4180 KB Output is correct
21 Correct 0 ms 340 KB Output is correct
22 Correct 1 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 0 ms 324 KB Output is correct
30 Correct 1 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 328 KB Output is correct
34 Correct 0 ms 332 KB Output is correct
35 Correct 0 ms 340 KB Output is correct
36 Correct 1 ms 468 KB Output is correct
37 Correct 1 ms 468 KB Output is correct
38 Correct 1 ms 468 KB Output is correct
39 Correct 0 ms 468 KB Output is correct
40 Correct 1 ms 468 KB Output is correct
41 Correct 0 ms 468 KB Output is correct
42 Correct 1 ms 468 KB Output is correct
43 Correct 1 ms 468 KB Output is correct
44 Correct 1 ms 468 KB Output is correct
45 Correct 1 ms 468 KB Output is correct
46 Correct 0 ms 452 KB Output is correct
47 Correct 1 ms 468 KB Output is correct
48 Correct 1 ms 452 KB Output is correct
49 Correct 1 ms 468 KB Output is correct
50 Correct 1 ms 452 KB Output is correct
51 Correct 1 ms 468 KB Output is correct
52 Correct 1 ms 460 KB Output is correct
53 Correct 1 ms 468 KB Output is correct
54 Correct 1 ms 468 KB Output is correct
55 Correct 1 ms 468 KB Output is correct
56 Correct 1 ms 468 KB Output is correct
57 Correct 1 ms 468 KB Output is correct
58 Correct 0 ms 468 KB Output is correct
59 Correct 1 ms 468 KB Output is correct
60 Correct 1 ms 468 KB Output is correct
61 Correct 1 ms 1108 KB Output is correct
62 Correct 1 ms 1108 KB Output is correct
63 Correct 1 ms 1108 KB Output is correct
64 Correct 1 ms 1108 KB Output is correct
65 Correct 1 ms 1108 KB Output is correct
66 Correct 1 ms 1108 KB Output is correct
67 Correct 1 ms 1108 KB Output is correct
68 Correct 2 ms 1108 KB Output is correct
69 Correct 2 ms 1108 KB Output is correct
70 Correct 2 ms 1092 KB Output is correct
71 Correct 2 ms 1108 KB Output is correct
72 Correct 2 ms 1108 KB Output is correct
73 Correct 1 ms 1108 KB Output is correct
74 Correct 1 ms 1108 KB Output is correct
75 Correct 2 ms 1092 KB Output is correct
76 Correct 1 ms 1108 KB Output is correct
77 Correct 1 ms 1096 KB Output is correct
78 Correct 1 ms 1108 KB Output is correct
79 Correct 1 ms 1108 KB Output is correct
80 Correct 1 ms 1108 KB Output is correct
81 Correct 131 ms 4288 KB Output is correct
82 Correct 159 ms 4288 KB Output is correct
83 Correct 130 ms 4308 KB Output is correct
84 Correct 130 ms 4284 KB Output is correct
85 Correct 132 ms 4308 KB Output is correct
86 Correct 131 ms 4180 KB Output is correct
87 Correct 157 ms 4288 KB Output is correct
88 Correct 4 ms 4180 KB Output is correct
89 Correct 4 ms 4180 KB Output is correct
90 Correct 11 ms 4312 KB Output is correct
91 Correct 11 ms 4304 KB Output is correct
92 Correct 38 ms 4180 KB Output is correct
93 Correct 45 ms 4288 KB Output is correct
94 Correct 78 ms 4292 KB Output is correct
95 Correct 76 ms 4284 KB Output is correct
96 Correct 116 ms 4288 KB Output is correct
97 Correct 115 ms 4308 KB Output is correct
98 Correct 66 ms 4308 KB Output is correct
99 Correct 64 ms 4180 KB Output is correct
100 Correct 65 ms 4308 KB Output is correct
101 Correct 67 ms 4300 KB Output is correct
102 Correct 66 ms 4180 KB Output is correct
103 Correct 68 ms 4308 KB Output is correct
104 Correct 64 ms 4180 KB Output is correct
105 Correct 65 ms 4308 KB Output is correct