Submission #594644

# Submission time Handle Problem Language Result Execution time Memory
594644 2022-07-12T18:56:44 Z 1ne Let's Win the Election (JOI22_ho_t3) C++14
0 / 100
2500 ms 1048576 KB
#include<bits/stdc++.h>
using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n,k;cin>>n>>k;
	vector<pair<double long,double long>>arr,temp;
	for (int i = 0;i<n;++i){
		double long x,y;cin>>x>>y;
		if (y == -1){
			temp.push_back({x,y});
		}
		else{
			arr.push_back({x,y});
		}
	}
	sort(arr.begin(),arr.end(),[&](auto x,auto y){
		if (x.second == y.second)return x.first < y.first;
		return x.second < y.second;
	});
	sort(temp.begin(),temp.end(),[&](auto x,auto y){
		return x.first < y.first;
	});
	for (auto x:temp)arr.push_back(x);
	double long left = 0,right = 1e9;
	double long ans = 0;
	double long mxn = 1e15;
	function<bool(double long)>check = [&](double long mid){
		vector<vector<vector<double long>>>dp(n + 1,vector<vector<double long>>(k + 1,vector<double long>(n + 1,-1)));
		function<double long(int,int,int)>solve = [&](int i,int j,int p){
			if (i == n){
				if (j == k)return (double long)0.0;
				return mxn;
			}
			if (j == k){
				return (double long)0.0;
			}
			if (dp[i][j][p]!= -1)return dp[i][j][p];
			double long ans = solve(i + 1,j,p);
			ans = min(ans,solve(i + 1,j + 1,p) + (double long)(arr[i].first / p));
			if (arr[i].second!=-1){
				ans = min(ans,solve(i + 1,j + 1,p + 1) + (double long)(arr[i].second / p));
			}
			return dp[i][j][p] = ans;
		};
		if (solve(0,0,1) <=mid){
			return true;
		}
		return false;
	};
	for (int i = 0;i<100;++i){
		double long mid = (left + right)/2;
		if (check(mid)){
			right = mid;
			ans = mid;
		}
		else left = mid;
	}
	cout<<fixed<<setprecision(15)<<ans<<'\n';
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Execution timed out 2564 ms 202244 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Execution timed out 2564 ms 202244 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 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 2 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Incorrect 1 ms 340 KB Output isn't correct
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 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 2 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Incorrect 1 ms 340 KB Output isn't correct
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 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 2 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Incorrect 1 ms 340 KB Output isn't correct
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 444 ms 1048576 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Execution timed out 2564 ms 202244 KB Time limit exceeded
6 Halted 0 ms 0 KB -