답안 #718960

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
718960 2023-04-05T07:50:44 Z Kalashnikov Let's Win the Election (JOI22_ho_t3) C++17
56 / 100
2500 ms 994492 KB
#include <bits/stdc++.h>
 
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)
#define all(a) a.begin() , a.end()
#define F first
#define S second
 
using namespace std;
using ll = long long;
 
const int N = 500+5 , inf = 2e9 + 7;
const ll INF = 1e18 ,   mod = 1e9+7 , P = 6547;

int a[N], b[N];

double dp[N][N][N];

void mini(double &a, double b) {
	a = min(a, b);
}

void solve(int tc) {
	int n , k;
	cin >> n >> k;
	vector<pair<int,int>> vec;
	for(int i = 1; i <= n; i ++) {
		cin >> a[i] >> b[i];
		if(b[i] == -1) b[i] = inf;
		vec.push_back({b[i] , a[i]});
	}
	sort(all(vec));
	for(int i = 1; i <= n; i ++) {
		a[i] = vec[i-1].S;
		b[i] = vec[i-1].F;
	}
	for(int i = 0; i <= n; i ++) {
		for(int j = 0; j <= n; j ++) {
			for(int k = 0; k <= n; k ++) {
				dp[i][j][k] = INF;
			}
		}
	}
	for(int i = 0; i <= n; i ++) dp[i][0][0] = 0;
	double ans = INF;
	for(int l = 0; l <= n; l ++) { // в конце сторонников
		for(int i = 0; i < n; i ++) {
			for(int j = 0; j <= i; j ++) {
				mini(dp[i+1][j][l], dp[i][j][l]);
				mini(dp[i+1][j+1][l], dp[i][j][l] + a[i+1]/double(l+1));
				for(int x = 0; x <= min(j, l); x ++) {
					mini(dp[i+1][j][x], dp[i][j][x]);
					mini(dp[i+1][j+1][x], dp[i][j][x] + a[i+1]/double(l+1));
					if(b[i+1] != inf)
						mini(dp[i+1][j+1][x+1], dp[i][j][x] + b[i+1]/double(x+1));
				}
			}
		}
		ans = min(ans, dp[n][k][l]);
	}
	// for(int x = 0; x <= n; x ++) {
		// ans = min(ans, dp[n][k][x]);
	// }
	cout << fixed << setprecision(6) << ans;
}
/*
*/
main() {
    ios;
    int tt = 1 , tc = 0;
    // cin >> tt;
    while(tt --) {
        solve(++tc);
    }
    return 0;
}

Compilation message

Main.cpp:68:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   68 | main() {
      | ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Execution timed out 2644 ms 994492 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Execution timed out 2644 ms 994492 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 596 KB Output is correct
2 Correct 1 ms 596 KB Output is correct
3 Correct 1 ms 596 KB Output is correct
4 Correct 1 ms 592 KB Output is correct
5 Correct 1 ms 596 KB Output is correct
6 Correct 1 ms 596 KB Output is correct
7 Correct 1 ms 596 KB Output is correct
8 Correct 1 ms 608 KB Output is correct
9 Correct 1 ms 584 KB Output is correct
10 Correct 1 ms 596 KB Output is correct
11 Correct 1 ms 596 KB Output is correct
12 Correct 1 ms 596 KB Output is correct
13 Correct 1 ms 596 KB Output is correct
14 Correct 1 ms 468 KB Output is correct
15 Correct 1 ms 596 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 596 KB Output is correct
2 Correct 1 ms 596 KB Output is correct
3 Correct 1 ms 596 KB Output is correct
4 Correct 1 ms 592 KB Output is correct
5 Correct 1 ms 596 KB Output is correct
6 Correct 1 ms 596 KB Output is correct
7 Correct 1 ms 596 KB Output is correct
8 Correct 1 ms 608 KB Output is correct
9 Correct 1 ms 584 KB Output is correct
10 Correct 1 ms 596 KB Output is correct
11 Correct 1 ms 596 KB Output is correct
12 Correct 1 ms 596 KB Output is correct
13 Correct 1 ms 596 KB Output is correct
14 Correct 1 ms 468 KB Output is correct
15 Correct 1 ms 596 KB Output is correct
16 Correct 2 ms 2132 KB Output is correct
17 Correct 1 ms 2132 KB Output is correct
18 Correct 1 ms 2124 KB Output is correct
19 Correct 2 ms 2132 KB Output is correct
20 Correct 2 ms 2132 KB Output is correct
21 Correct 2 ms 2124 KB Output is correct
22 Correct 1 ms 2132 KB Output is correct
23 Correct 1 ms 2132 KB Output is correct
24 Correct 1 ms 2128 KB Output is correct
25 Correct 1 ms 2124 KB Output is correct
26 Correct 1 ms 2132 KB Output is correct
27 Correct 1 ms 2132 KB Output is correct
28 Correct 2 ms 2132 KB Output is correct
29 Correct 2 ms 2132 KB Output is correct
30 Correct 2 ms 2156 KB Output is correct
31 Correct 1 ms 2132 KB Output is correct
32 Correct 1 ms 2132 KB Output is correct
33 Correct 1 ms 2128 KB Output is correct
34 Correct 1 ms 2124 KB Output is correct
35 Correct 1 ms 2132 KB Output is correct
36 Correct 1 ms 2132 KB Output is correct
37 Correct 1 ms 2132 KB Output is correct
38 Correct 1 ms 2120 KB Output is correct
39 Correct 1 ms 2132 KB Output is correct
40 Correct 1 ms 2120 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 596 KB Output is correct
2 Correct 1 ms 596 KB Output is correct
3 Correct 1 ms 596 KB Output is correct
4 Correct 1 ms 592 KB Output is correct
5 Correct 1 ms 596 KB Output is correct
6 Correct 1 ms 596 KB Output is correct
7 Correct 1 ms 596 KB Output is correct
8 Correct 1 ms 608 KB Output is correct
9 Correct 1 ms 584 KB Output is correct
10 Correct 1 ms 596 KB Output is correct
11 Correct 1 ms 596 KB Output is correct
12 Correct 1 ms 596 KB Output is correct
13 Correct 1 ms 596 KB Output is correct
14 Correct 1 ms 468 KB Output is correct
15 Correct 1 ms 596 KB Output is correct
16 Correct 2 ms 2132 KB Output is correct
17 Correct 1 ms 2132 KB Output is correct
18 Correct 1 ms 2124 KB Output is correct
19 Correct 2 ms 2132 KB Output is correct
20 Correct 2 ms 2132 KB Output is correct
21 Correct 2 ms 2124 KB Output is correct
22 Correct 1 ms 2132 KB Output is correct
23 Correct 1 ms 2132 KB Output is correct
24 Correct 1 ms 2128 KB Output is correct
25 Correct 1 ms 2124 KB Output is correct
26 Correct 1 ms 2132 KB Output is correct
27 Correct 1 ms 2132 KB Output is correct
28 Correct 2 ms 2132 KB Output is correct
29 Correct 2 ms 2132 KB Output is correct
30 Correct 2 ms 2156 KB Output is correct
31 Correct 1 ms 2132 KB Output is correct
32 Correct 1 ms 2132 KB Output is correct
33 Correct 1 ms 2128 KB Output is correct
34 Correct 1 ms 2124 KB Output is correct
35 Correct 1 ms 2132 KB Output is correct
36 Correct 1 ms 2132 KB Output is correct
37 Correct 1 ms 2132 KB Output is correct
38 Correct 1 ms 2120 KB Output is correct
39 Correct 1 ms 2132 KB Output is correct
40 Correct 1 ms 2120 KB Output is correct
41 Correct 55 ms 41040 KB Output is correct
42 Correct 53 ms 41044 KB Output is correct
43 Correct 60 ms 41044 KB Output is correct
44 Correct 50 ms 41044 KB Output is correct
45 Correct 54 ms 41040 KB Output is correct
46 Correct 60 ms 41044 KB Output is correct
47 Correct 52 ms 41044 KB Output is correct
48 Correct 45 ms 41048 KB Output is correct
49 Correct 55 ms 41048 KB Output is correct
50 Correct 50 ms 41044 KB Output is correct
51 Correct 55 ms 41044 KB Output is correct
52 Correct 70 ms 41056 KB Output is correct
53 Correct 58 ms 41044 KB Output is correct
54 Correct 68 ms 40996 KB Output is correct
55 Correct 55 ms 41000 KB Output is correct
56 Correct 52 ms 41044 KB Output is correct
57 Correct 53 ms 41036 KB Output is correct
58 Correct 65 ms 41000 KB Output is correct
59 Correct 52 ms 41048 KB Output is correct
60 Correct 71 ms 41048 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2609 ms 994432 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Execution timed out 2644 ms 994492 KB Time limit exceeded
6 Halted 0 ms 0 KB -