Submission #532049

# Submission time Handle Problem Language Result Execution time Memory
532049 2022-03-02T04:29:25 Z Haruto810198 Let's Win the Election (JOI22_ho_t3) C++17
56 / 100
2500 ms 976 KB
#include <bits/stdc++.h>

using namespace std;

#define int long long
#define double long double

#define FOR(i, l, r, d) for(int i=(l); i<=(r); i+=(d))
#define szof(x) ((int)(x).size())

#define vi vector<int>
#define pii pair<int, int>

#define F first
#define S second

#define pb push_back
#define eb emplace_back
#define mkp make_pair

const int INF = INT_MAX;
const int LNF = INF*INF;
const int MOD = 1000000007;
const int mod = 998244353;
const double eps = 1e-12;

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")

const int MAX = 510;

struct State{
	double A, B;	
};

int n, k;
State state[MAX];
double res;

double dp[MAX][MAX];

bool cmp_by_B(State x, State y){
	if(x.B == y.B) return (x.A < y.A);
	return (x.B < y.B);
}

signed main(){
	
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	
	cin>>n>>k;
	FOR(i, 1, n, 1){
		cin>>state[i].A>>state[i].B;
		if(state[i].B == -1) state[i].B = INF;
	}
	sort(state+1, state+n+1, cmp_by_B);
	
	res = INF;
	// enum. n. of collaborators
	FOR(C, 0, k, 1){
		int V = k - C;
		// C collaborators, V votes
		
		FOR(i, 0, C, 1){
			FOR(j, 0, V, 1){
				dp[i][j] = INF;
			}
		}
		dp[0][0] = 0;

		FOR(x, 1, n, 1){
			for(int i = C; i >= 0; i--){
				for(int j = V; j >= 0; j--){
					if(i > 0) dp[i][j] = min(dp[i][j], dp[i-1][j] + state[x].B / i);
					if(j > 0) dp[i][j] = min(dp[i][j], dp[i][j-1] + state[x].A / (C+1));
				}
			}
		}

		res = min(res, dp[C][V]);
	}

	cout<<fixed<<setprecision(12)<<res<<'\n';
	
	return 0;

}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 352 KB Output is correct
2 Correct 0 ms 320 KB Output is correct
3 Correct 0 ms 332 KB Output is correct
4 Correct 1 ms 316 KB Output is correct
5 Correct 185 ms 452 KB Output is correct
6 Correct 2469 ms 976 KB Output is correct
7 Execution timed out 2574 ms 600 KB Time limit exceeded
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 352 KB Output is correct
2 Correct 0 ms 320 KB Output is correct
3 Correct 0 ms 332 KB Output is correct
4 Correct 1 ms 316 KB Output is correct
5 Correct 185 ms 452 KB Output is correct
6 Correct 2469 ms 976 KB Output is correct
7 Execution timed out 2574 ms 600 KB Time limit exceeded
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 320 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 324 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 320 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 320 KB Output is correct
12 Correct 0 ms 332 KB Output is correct
13 Correct 0 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 324 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 320 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 324 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 320 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 320 KB Output is correct
12 Correct 0 ms 332 KB Output is correct
13 Correct 0 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 324 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 296 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 1 ms 332 KB Output is correct
24 Correct 1 ms 332 KB Output is correct
25 Correct 1 ms 316 KB Output is correct
26 Correct 1 ms 384 KB Output is correct
27 Correct 1 ms 320 KB Output is correct
28 Correct 1 ms 332 KB Output is correct
29 Correct 1 ms 332 KB Output is correct
30 Correct 1 ms 332 KB Output is correct
31 Correct 1 ms 324 KB Output is correct
32 Correct 1 ms 332 KB Output is correct
33 Correct 1 ms 332 KB Output is correct
34 Correct 1 ms 332 KB Output is correct
35 Correct 1 ms 332 KB Output is correct
36 Correct 1 ms 332 KB Output is correct
37 Correct 1 ms 332 KB Output is correct
38 Correct 1 ms 332 KB Output is correct
39 Correct 1 ms 332 KB Output is correct
40 Correct 1 ms 324 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 320 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 324 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 320 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 320 KB Output is correct
12 Correct 0 ms 332 KB Output is correct
13 Correct 0 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 324 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 296 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 1 ms 332 KB Output is correct
24 Correct 1 ms 332 KB Output is correct
25 Correct 1 ms 316 KB Output is correct
26 Correct 1 ms 384 KB Output is correct
27 Correct 1 ms 320 KB Output is correct
28 Correct 1 ms 332 KB Output is correct
29 Correct 1 ms 332 KB Output is correct
30 Correct 1 ms 332 KB Output is correct
31 Correct 1 ms 324 KB Output is correct
32 Correct 1 ms 332 KB Output is correct
33 Correct 1 ms 332 KB Output is correct
34 Correct 1 ms 332 KB Output is correct
35 Correct 1 ms 332 KB Output is correct
36 Correct 1 ms 332 KB Output is correct
37 Correct 1 ms 332 KB Output is correct
38 Correct 1 ms 332 KB Output is correct
39 Correct 1 ms 332 KB Output is correct
40 Correct 1 ms 324 KB Output is correct
41 Correct 2 ms 316 KB Output is correct
42 Correct 1 ms 316 KB Output is correct
43 Correct 9 ms 460 KB Output is correct
44 Correct 9 ms 332 KB Output is correct
45 Correct 31 ms 420 KB Output is correct
46 Correct 30 ms 504 KB Output is correct
47 Correct 67 ms 560 KB Output is correct
48 Correct 67 ms 524 KB Output is correct
49 Correct 126 ms 648 KB Output is correct
50 Correct 139 ms 580 KB Output is correct
51 Correct 237 ms 748 KB Output is correct
52 Correct 235 ms 772 KB Output is correct
53 Correct 81 ms 488 KB Output is correct
54 Correct 77 ms 580 KB Output is correct
55 Correct 73 ms 544 KB Output is correct
56 Correct 66 ms 500 KB Output is correct
57 Correct 76 ms 516 KB Output is correct
58 Correct 94 ms 564 KB Output is correct
59 Correct 74 ms 504 KB Output is correct
60 Correct 72 ms 708 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 2564 ms 640 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 352 KB Output is correct
2 Correct 0 ms 320 KB Output is correct
3 Correct 0 ms 332 KB Output is correct
4 Correct 1 ms 316 KB Output is correct
5 Correct 185 ms 452 KB Output is correct
6 Correct 2469 ms 976 KB Output is correct
7 Execution timed out 2574 ms 600 KB Time limit exceeded
8 Halted 0 ms 0 KB -