답안 #681791

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
681791 2023-01-14T10:21:04 Z dsyz Let's Win the Election (JOI22_ho_t3) C++17
10 / 100
635 ms 4252 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 Rie 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 = min(K,i + 1);a >= 0;a--){
			for(ll b = a;b >= 0;b--){
				if(a == 0){
					dp[a][b] = 0;
				}else if(b == 0){
					dp[a][b] = min(dp[a][b],dp[a - 1][b] + A[i]);
					dp[a][b] = round(dp[a][b] * 1000) / 1000;
				}else if(B[i] == -1){
					dp[a][b] = min(dp[a][b],dp[a - 1][b] + (A[i] / ld(b + 1)));
					dp[a][b] = round(dp[a][b] * 1000) / 1000;
				}else{
					dp[a][b] = min(dp[a][b],min(dp[a - 1][b] + (A[i] / ld(b + 1)),
					dp[a - 1][b - 1] + (B[i] / ld(b))));
					dp[a][b] = round(dp[a][b] * 1000) / 1000;
				}
			}
		}
	}
	ld minimum = 1e18;
	for(ll j = 0;j <= N;j++){
		minimum = min(minimum,dp[K][j]);
	}
	cout<<minimum<<'\n';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 15 ms 724 KB Output is correct
6 Correct 79 ms 1308 KB Output is correct
7 Correct 252 ms 2284 KB Output is correct
8 Correct 408 ms 3284 KB Output is correct
9 Correct 515 ms 4180 KB Output is correct
10 Correct 381 ms 3068 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 15 ms 724 KB Output is correct
6 Correct 79 ms 1308 KB Output is correct
7 Correct 252 ms 2284 KB Output is correct
8 Correct 408 ms 3284 KB Output is correct
9 Correct 515 ms 4180 KB Output is correct
10 Correct 381 ms 3068 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 134 ms 1504 KB Output is correct
13 Correct 123 ms 1492 KB Output is correct
14 Correct 113 ms 1492 KB Output is correct
15 Correct 425 ms 3068 KB Output is correct
16 Correct 442 ms 3072 KB Output is correct
17 Correct 406 ms 3076 KB Output is correct
18 Correct 529 ms 4248 KB Output is correct
19 Correct 589 ms 4248 KB Output is correct
20 Correct 503 ms 4252 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 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 0 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 1 ms 212 KB Output is correct
9 Incorrect 0 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 1 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 0 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 1 ms 212 KB Output is correct
9 Incorrect 0 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 1 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 0 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 1 ms 212 KB Output is correct
9 Incorrect 0 ms 212 KB Output isn't correct
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 635 ms 4248 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 15 ms 724 KB Output is correct
6 Correct 79 ms 1308 KB Output is correct
7 Correct 252 ms 2284 KB Output is correct
8 Correct 408 ms 3284 KB Output is correct
9 Correct 515 ms 4180 KB Output is correct
10 Correct 381 ms 3068 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 134 ms 1504 KB Output is correct
13 Correct 123 ms 1492 KB Output is correct
14 Correct 113 ms 1492 KB Output is correct
15 Correct 425 ms 3068 KB Output is correct
16 Correct 442 ms 3072 KB Output is correct
17 Correct 406 ms 3076 KB Output is correct
18 Correct 529 ms 4248 KB Output is correct
19 Correct 589 ms 4248 KB Output is correct
20 Correct 503 ms 4252 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Correct 0 ms 212 KB Output is correct
25 Correct 0 ms 212 KB Output is correct
26 Correct 0 ms 212 KB Output is correct
27 Correct 0 ms 212 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
29 Incorrect 0 ms 212 KB Output isn't correct
30 Halted 0 ms 0 KB -