Submission #937920

# Submission time Handle Problem Language Result Execution time Memory
937920 2024-03-04T16:44:48 Z Litusiano Let's Win the Election (JOI22_ho_t3) C++17
0 / 100
630 ms 1048576 KB
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl "\n"
const int INF = 1e18;
bool cmp(pair<int,int> a, pair<int,int> b){
	if(a.second == b.second) return a.first < b.first;
	return a.second < b.second;
}

signed main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n,k1; cin>>n>>k1;
	vector<pair<int,int>> v(n);
	for(int i = 0; i<n; i++){
		cin>>v[i].first>>v[i].second;
		if(v[i].second == -1) v[i].second = INF;
	}
	sort(v.begin(),v.end(),cmp);
	long double dp[n+1][n+1][n+1];
	for(int i = 0; i<=n; i++){
		for(int j = 0; j<=n; j++){
			for(int k = 0; k<=n; k++) dp[i][j][k] = INF;
		}
	}
	dp[0][0][0] = 0; // first i, j votes, k representants
	long double ans = INF;
	for(int i = 1; i<=n; i++){
		for(int j = 0; j<=n; j++){
			for(int k = 0; k<=n; k++){
				dp[i][j][k] = dp[i-1][j][k];
				if(!j) continue;
				long double act = dp[i-1][j-1][k]; // just speech for vote
				act+= 1.0*v[i-1].first/(k+1);
				dp[i][j][k] = min(dp[i][j][k],act);
				if(!k || v[i-1].second == INF) continue;
				act = dp[i-1][j-1][k-1];
				act+= 1.0*v[i-1].second / k;
				dp[i][j][k] = min(dp[i][j][k],act);
			}
		}
	}
	for(int k = 0; k<=n; k++){
		ans = min(ans, dp[n][k1][k]);
	}
	cout<<setprecision(10)<<fixed<<ans<<endl;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Runtime error 630 ms 1048576 KB Execution killed with signal 9
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Runtime error 630 ms 1048576 KB Execution killed with signal 9
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 600 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 456 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 452 KB Output is correct
9 Incorrect 1 ms 348 KB Output isn't correct
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 600 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 456 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 452 KB Output is correct
9 Incorrect 1 ms 348 KB Output isn't correct
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 600 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 456 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 452 KB Output is correct
9 Incorrect 1 ms 348 KB Output isn't correct
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 558 ms 1048576 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Runtime error 630 ms 1048576 KB Execution killed with signal 9
6 Halted 0 ms 0 KB -