Submission #681707

# Submission time Handle Problem Language Result Execution time Memory
681707 2023-01-13T20:03:02 Z dsyz Let's Win the Election (JOI22_ho_t3) C++17
0 / 100
821 ms 4248 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define MAXN (300005)
int main() {
	ios_base::sync_with_stdio(false);cin.tie(0);
	ll N,K;
	cin>>N>>K;
	pair<ll,ll> arr[N];
	for(ll i = 0;i < N;i++){
		cin>>arr[i].second>>arr[i].first;
		if(arr[i].first == -1) arr[i].first = 1e18;
	}
	sort(arr,arr + N);
	ld A[N], B[N];
	for(ll i = 0;i < N;i++){
		A[i] = arr[i].second;
		B[i] = arr[i].first;
		if(arr[i].first == 1e18){
			arr[i].first = -1;
			B[i] = -1;
		}
	}
	ld dp[K + 1][N + 1]; //number of A fufilled, number of collaborators (excluding Ria herself)
	for(ll i = 0;i <= K;i++){
		for(ll j = 0;j <= N;j++){
			dp[i][j] = 1e18;
		}
	}
	dp[0][0] = 0;
	for(ll i = 0;i < N;i++){
		for(ll a = 0;a <= K;a++){
			for(ll b = 0;b <= a;b++){
				if(a == 0){
					dp[a][b] = 0;
				}else if(B[i] == -1){
					dp[a][b] = min(dp[a][b],dp[a - 1][b] + (A[i] / ld(b)));
				}else{
					dp[a][b] = min(dp[a][b],min(dp[a - 1][b] + (A[i] / ld(b)),
					dp[a - 1][b - 1] + (B[i] / ld(b))));
				}
			}
		}
	}
	ld minimum = 1e18;
	for(ll j = 0;j <= N;j++){
		minimum = min(minimum,dp[K][j]);
	}
	cout<<minimum<<'\n';
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 320 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 320 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 320 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 821 ms 4248 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -