답안 #923370

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
923370 2024-02-07T07:03:36 Z goodspeed0208 Let's Win the Election (JOI22_ho_t3) C++14
10 / 100
570 ms 1018984 KB
#include<bits/stdc++.h>
#define pii pair<int, int>
#define INF 5000000
using namespace std;

bool cmp(pii a, pii b) {
	if (a.second == -1 || b.second == -1) return a.second != -1;
	return a.second < b.second;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, K;
	cin >> n >> K;
	vector<pii>v(n+1);
	vector<double>a(n+1), b(n+1);
	for (int i = 1 ; i <=  n ;i++) cin >> v[i].first >> v[i].second;
	sort(v.begin()+1, v.end(), cmp);
	for (int i = 1 ; i <= n ;i++) a[i] = (double)v[i].first, b[i] = (double)v[i].second;
	
	vector<vector<vector<double> > >dp(505, vector<vector<double> >(505, vector<double>(505, INF)) );
	//double dp[505][505][505];
	dp[0][0][1] = 0.0;
	double ans = INF;
	for (int i = 1 ; i <= n ; i++) {//first i people
	//cout << i << ": \n";
		for (int j = 0 ; j <= i ; j++) {// have how many people
			//cout << j << ": ";
			for (int k = 1 ; k <= j+1 ; k++) {// get how many people
				dp[i][j][k] = dp[i-1][j][k];
				if (j > 0) dp[i][j][k] = min(dp[i][j][k], dp[i-1][j-1][k] + (a[i] / k));
				if (k > 1 && b[i] != -1) dp[i][j][k] = min(dp[i][j][k], dp[i-1][j-1][k-1] + b[i] / (k-1));
				//cout << dp[i][j][k] <<" ";
				if (j >= K) ans = min(ans, dp[i][j][k]);
			}
			//cout << "\n";
		}
	}
	cout << fixed << setprecision(6) << ans << "\n";
	//for (auto &i : v) cout << i.first <<" " << i.second << "\n";
}
# 결과 실행 시간 메모리 Grader output
1 Correct 433 ms 1018324 KB Output is correct
2 Correct 403 ms 1018708 KB Output is correct
3 Correct 379 ms 1018348 KB Output is correct
4 Correct 376 ms 1018700 KB Output is correct
5 Correct 570 ms 1018448 KB Output is correct
6 Correct 554 ms 1018564 KB Output is correct
7 Correct 501 ms 1018688 KB Output is correct
8 Correct 434 ms 1018412 KB Output is correct
9 Correct 445 ms 1018836 KB Output is correct
10 Correct 447 ms 1018764 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 433 ms 1018324 KB Output is correct
2 Correct 403 ms 1018708 KB Output is correct
3 Correct 379 ms 1018348 KB Output is correct
4 Correct 376 ms 1018700 KB Output is correct
5 Correct 570 ms 1018448 KB Output is correct
6 Correct 554 ms 1018564 KB Output is correct
7 Correct 501 ms 1018688 KB Output is correct
8 Correct 434 ms 1018412 KB Output is correct
9 Correct 445 ms 1018836 KB Output is correct
10 Correct 447 ms 1018764 KB Output is correct
11 Correct 410 ms 1018452 KB Output is correct
12 Correct 462 ms 1018736 KB Output is correct
13 Correct 446 ms 1018572 KB Output is correct
14 Correct 437 ms 1018444 KB Output is correct
15 Correct 465 ms 1018984 KB Output is correct
16 Correct 445 ms 1018624 KB Output is correct
17 Correct 432 ms 1018584 KB Output is correct
18 Correct 465 ms 1018396 KB Output is correct
19 Correct 434 ms 1018580 KB Output is correct
20 Correct 442 ms 1018964 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 419 ms 1018352 KB Output is correct
2 Correct 384 ms 1018732 KB Output is correct
3 Correct 403 ms 1018448 KB Output is correct
4 Correct 386 ms 1018416 KB Output is correct
5 Correct 377 ms 1018364 KB Output is correct
6 Correct 378 ms 1018324 KB Output is correct
7 Correct 372 ms 1018452 KB Output is correct
8 Correct 380 ms 1018392 KB Output is correct
9 Incorrect 390 ms 1018568 KB Output isn't correct
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 419 ms 1018352 KB Output is correct
2 Correct 384 ms 1018732 KB Output is correct
3 Correct 403 ms 1018448 KB Output is correct
4 Correct 386 ms 1018416 KB Output is correct
5 Correct 377 ms 1018364 KB Output is correct
6 Correct 378 ms 1018324 KB Output is correct
7 Correct 372 ms 1018452 KB Output is correct
8 Correct 380 ms 1018392 KB Output is correct
9 Incorrect 390 ms 1018568 KB Output isn't correct
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 419 ms 1018352 KB Output is correct
2 Correct 384 ms 1018732 KB Output is correct
3 Correct 403 ms 1018448 KB Output is correct
4 Correct 386 ms 1018416 KB Output is correct
5 Correct 377 ms 1018364 KB Output is correct
6 Correct 378 ms 1018324 KB Output is correct
7 Correct 372 ms 1018452 KB Output is correct
8 Correct 380 ms 1018392 KB Output is correct
9 Incorrect 390 ms 1018568 KB Output isn't correct
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 489 ms 1018536 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 433 ms 1018324 KB Output is correct
2 Correct 403 ms 1018708 KB Output is correct
3 Correct 379 ms 1018348 KB Output is correct
4 Correct 376 ms 1018700 KB Output is correct
5 Correct 570 ms 1018448 KB Output is correct
6 Correct 554 ms 1018564 KB Output is correct
7 Correct 501 ms 1018688 KB Output is correct
8 Correct 434 ms 1018412 KB Output is correct
9 Correct 445 ms 1018836 KB Output is correct
10 Correct 447 ms 1018764 KB Output is correct
11 Correct 410 ms 1018452 KB Output is correct
12 Correct 462 ms 1018736 KB Output is correct
13 Correct 446 ms 1018572 KB Output is correct
14 Correct 437 ms 1018444 KB Output is correct
15 Correct 465 ms 1018984 KB Output is correct
16 Correct 445 ms 1018624 KB Output is correct
17 Correct 432 ms 1018584 KB Output is correct
18 Correct 465 ms 1018396 KB Output is correct
19 Correct 434 ms 1018580 KB Output is correct
20 Correct 442 ms 1018964 KB Output is correct
21 Correct 419 ms 1018352 KB Output is correct
22 Correct 384 ms 1018732 KB Output is correct
23 Correct 403 ms 1018448 KB Output is correct
24 Correct 386 ms 1018416 KB Output is correct
25 Correct 377 ms 1018364 KB Output is correct
26 Correct 378 ms 1018324 KB Output is correct
27 Correct 372 ms 1018452 KB Output is correct
28 Correct 380 ms 1018392 KB Output is correct
29 Incorrect 390 ms 1018568 KB Output isn't correct
30 Halted 0 ms 0 KB -