답안 #594658

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
594658 2022-07-12T19:17:24 Z 1ne Let's Win the Election (JOI22_ho_t3) C++14
0 / 100
2500 ms 8452 KB
#include<bits/stdc++.h>
using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	double long 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 mxn = 1e12;
	vector<vector<double long>>dp(n + 1,vector<double long>(n + 1,mxn));
	dp[0][0] = 0.0;
	for (int i = 0;i<n;++i){
		vector<vector<double long>>cur_dp(n + 1,vector<double long>(n + 1,mxn));
		for (int j = 0;j<n;++j){
			for (int p = 0;p < n;++p){
				cur_dp[j][p] = min(cur_dp[j][p],dp[j][p]);
				cur_dp[j + 1][p + 1] = min(cur_dp[j + 1][p + 1],dp[j + 1][p + 1]);
				cur_dp[j + 1][p] = min(cur_dp[j + 1][p],dp[j + 1][p]);
				if (arr[i].second!=-1){
					cur_dp[j + 1][p + 1] = min(dp[j][p] + (double long)(arr[i].second / (p + 1)),cur_dp[j + 1][p + 1]);
				}
				cur_dp[j + 1][p] =  min(cur_dp[j + 1][p],dp[j][p] + (double long)(arr[i].first / (p + 1)));
			}
		}
		swap(cur_dp,dp);
	}
	double long ans = mxn;
	for (int i = 0;i<=n;++i){
		ans = min(ans,dp[k][i]);
	}
	cout<<fixed<<setprecision(15)<<ans<<'\n';
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Execution timed out 2567 ms 8452 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Execution timed out 2567 ms 8452 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Incorrect 1 ms 212 KB Output isn't correct
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Incorrect 1 ms 212 KB Output isn't correct
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Incorrect 1 ms 212 KB Output isn't correct
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2560 ms 8372 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Execution timed out 2567 ms 8452 KB Time limit exceeded
6 Halted 0 ms 0 KB -