Submission #863835

# Submission time Handle Problem Language Result Execution time Memory
863835 2023-10-21T08:37:43 Z phoenix0423 Let's Win the Election (JOI22_ho_t3) C++17
10 / 100
827 ms 5004 KB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<double, double> pll;
#define fastio ios::sync_with_stdio(false), cin.tie(0)
#pragma GCC optimize("Ofast")
#define pb push_back
#define eb emplace_back
#define f first
#define s second
#define lowbit(x) x&-x
const int maxn = 2e5 + 5;
const double INF = 8e18;

int main(void){
	fastio;
	int n, k;
	cin>>n>>k;
	vector<pll> a(n);
	for(int i = 0; i < n; i++){
		cin>>a[i].f>>a[i].s;
		if(a[i].s == -1) a[i].s = INF;
	}
	sort(a.begin(), a.end(), [&](pll a, pll b){ return a.s < b.s;});
	vector<vector<double>> dp(n + 5, vector<double>(n + 5, INF));
	dp[0][1] = 0;
	for(int i = 0; i < n; i++){
		auto [v0, v1] = a[i];
		vector<vector<double>> ndp(dp);
		for(int j = 0; j <= k; j++){
			for(int cnt = 1; cnt <= k; cnt++){
				ndp[j + 1][cnt] = min(ndp[j + 1][cnt], dp[j][cnt] + v0 / cnt);
				if(v1 != -1) ndp[j + 1][cnt + 1] = min(ndp[j + 1][cnt + 1], dp[j][cnt] + v1 / cnt);
			}
		}
		swap(dp, ndp);
	}
	double ans = INF;
	for(int cnt = 1; cnt <= k; cnt++){
		ans = min(ans, dp[k][cnt]);
	}
	cout<<fixed<<setprecision(5)<<ans<<"\n";
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 161 ms 4484 KB Output is correct
6 Correct 196 ms 4712 KB Output is correct
7 Correct 297 ms 4904 KB Output is correct
8 Correct 476 ms 4468 KB Output is correct
9 Correct 704 ms 4700 KB Output is correct
10 Correct 431 ms 4592 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 161 ms 4484 KB Output is correct
6 Correct 196 ms 4712 KB Output is correct
7 Correct 297 ms 4904 KB Output is correct
8 Correct 476 ms 4468 KB Output is correct
9 Correct 704 ms 4700 KB Output is correct
10 Correct 431 ms 4592 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 223 ms 4592 KB Output is correct
13 Correct 212 ms 4684 KB Output is correct
14 Correct 209 ms 4708 KB Output is correct
15 Correct 423 ms 4536 KB Output is correct
16 Correct 429 ms 4536 KB Output is correct
17 Correct 429 ms 5004 KB Output is correct
18 Correct 695 ms 4500 KB Output is correct
19 Correct 693 ms 4648 KB Output is correct
20 Correct 703 ms 4716 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Incorrect 0 ms 348 KB Output isn't correct
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Incorrect 0 ms 348 KB Output isn't correct
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Incorrect 0 ms 348 KB Output isn't correct
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 827 ms 4932 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 161 ms 4484 KB Output is correct
6 Correct 196 ms 4712 KB Output is correct
7 Correct 297 ms 4904 KB Output is correct
8 Correct 476 ms 4468 KB Output is correct
9 Correct 704 ms 4700 KB Output is correct
10 Correct 431 ms 4592 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 223 ms 4592 KB Output is correct
13 Correct 212 ms 4684 KB Output is correct
14 Correct 209 ms 4708 KB Output is correct
15 Correct 423 ms 4536 KB Output is correct
16 Correct 429 ms 4536 KB Output is correct
17 Correct 429 ms 5004 KB Output is correct
18 Correct 695 ms 4500 KB Output is correct
19 Correct 693 ms 4648 KB Output is correct
20 Correct 703 ms 4716 KB Output is correct
21 Correct 0 ms 344 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Incorrect 0 ms 348 KB Output isn't correct
30 Halted 0 ms 0 KB -