답안 #1043414

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1043414 2024-08-04T09:12:37 Z Lucpp Let's Win the Election (JOI22_ho_t3) C++17
56 / 100
2500 ms 1056 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define sz(x) (int)size(x)
#define all(x) (x).begin(), (x).end()
constexpr double inf = 1e18;

double pmin(double &a, double b){
	return a = min(a, b);
}

int main(){
	cin.tie(0)->sync_with_stdio(false);
	int n, k;
	cin >> n >> k;
	vector<double> a(n), b(n);
	for(int i = 0; i < n; i++) cin >> a[i] >> b[i];
	{
		vector<int> ord(n);
		for(int i = 0; i < n; i++) ord[i] = i;
		sort(all(ord), [&](int i, int j){return b[i] < b[j];});
		vector<double> a2(n), b2(n);
		for(int i = 0; i < n; i++) a2[i] = a[ord[i]], b2[i] = b[ord[i]];
		a = a2, b = b2;
	}
	double ans = inf;
	for(int l = 0; l <= k; l++){
		vector<vector<double>> dp(l+1, vector<double>(k-l+1, inf));
		dp[0][0] = 0;
		for(int i = 0; i < n; i++){
			auto dp2 = dp;
			for(int j = 0; j <= l; j++){
				for(int h = 0; h <= k-l; h++){
					if(j < l && b[i] > 0) pmin(dp2[j+1][h], dp[j][h] + b[i] / (1+j));
					if(h < k-l) pmin(dp2[j][h+1], dp[j][h] + a[i] / (1+l));
				}
			}
			swap(dp, dp2);
		}
		ans = min(ans, dp[l][k-l]);
	}
	cout << setprecision(6) << fixed << ans << "\n";
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 33 ms 520 KB Output is correct
6 Correct 364 ms 840 KB Output is correct
7 Correct 2317 ms 856 KB Output is correct
8 Execution timed out 2543 ms 1000 KB Time limit exceeded
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 33 ms 520 KB Output is correct
6 Correct 364 ms 840 KB Output is correct
7 Correct 2317 ms 856 KB Output is correct
8 Execution timed out 2543 ms 1000 KB Time limit exceeded
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 452 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 452 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 604 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 0 ms 452 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 0 ms 456 KB Output is correct
24 Correct 1 ms 344 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 1 ms 344 KB Output is correct
32 Correct 0 ms 456 KB Output is correct
33 Correct 1 ms 348 KB Output is correct
34 Correct 0 ms 344 KB Output is correct
35 Correct 0 ms 348 KB Output is correct
36 Correct 0 ms 348 KB Output is correct
37 Correct 1 ms 344 KB Output is correct
38 Correct 0 ms 348 KB Output is correct
39 Correct 0 ms 348 KB Output is correct
40 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 452 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 604 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 0 ms 452 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 0 ms 456 KB Output is correct
24 Correct 1 ms 344 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 1 ms 344 KB Output is correct
32 Correct 0 ms 456 KB Output is correct
33 Correct 1 ms 348 KB Output is correct
34 Correct 0 ms 344 KB Output is correct
35 Correct 0 ms 348 KB Output is correct
36 Correct 0 ms 348 KB Output is correct
37 Correct 1 ms 344 KB Output is correct
38 Correct 0 ms 348 KB Output is correct
39 Correct 0 ms 348 KB Output is correct
40 Correct 0 ms 348 KB Output is correct
41 Correct 1 ms 348 KB Output is correct
42 Correct 1 ms 348 KB Output is correct
43 Correct 2 ms 348 KB Output is correct
44 Correct 2 ms 348 KB Output is correct
45 Correct 10 ms 348 KB Output is correct
46 Correct 9 ms 532 KB Output is correct
47 Correct 19 ms 540 KB Output is correct
48 Correct 21 ms 344 KB Output is correct
49 Correct 36 ms 604 KB Output is correct
50 Correct 32 ms 600 KB Output is correct
51 Correct 59 ms 604 KB Output is correct
52 Correct 56 ms 624 KB Output is correct
53 Correct 19 ms 348 KB Output is correct
54 Correct 19 ms 344 KB Output is correct
55 Correct 18 ms 540 KB Output is correct
56 Correct 20 ms 468 KB Output is correct
57 Correct 18 ms 348 KB Output is correct
58 Correct 19 ms 548 KB Output is correct
59 Correct 18 ms 348 KB Output is correct
60 Correct 22 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2542 ms 1056 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 33 ms 520 KB Output is correct
6 Correct 364 ms 840 KB Output is correct
7 Correct 2317 ms 856 KB Output is correct
8 Execution timed out 2543 ms 1000 KB Time limit exceeded
9 Halted 0 ms 0 KB -