Submission #939858

# Submission time Handle Problem Language Result Execution time Memory
939858 2024-03-06T20:34:27 Z TAhmed33 Let's Win the Election (JOI22_ho_t3) C++
0 / 100
466 ms 766316 KB
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
int n, k, a[501], b[501];
ld dp[1 << 20][23];
ld recurse (int mask, int c, int l) {
	if (l == k) return 0;
	ld &ret = dp[mask][c];
	if (ret == ret) return ret;
	ret = 1e18;
	for (int i = 0; i < n; i++) {
		if (mask & (1 << i)) continue;
		ret = min(ret, 1.0 * a[i] / c + recurse(mask ^ (1 << i), c, l + 1));
	}
	int pos = -1;
	for (int i = 0; i < n; i++) {
		if (mask & (1 << i)) continue;
		if (b[i] == -1) continue;
		if (pos == -1 || b[i] < b[pos]) pos = i;
	}
	if (pos != -1) {
		ret = min(ret, 1.0 * b[pos] / c + recurse(mask ^ (1 << pos), c + 1, l + 1));
	}
	return ret;
}
int main () {
	memset(dp, -1, sizeof(dp));
	cin >> n >> k;
	for (int i = 0; i < n; i++) cin >> a[i] >> b[i];
	cout << fixed << setprecision(9) << recurse(0, 1, 0) << '\n';
}
# Verdict Execution time Memory Grader output
1 Correct 135 ms 377940 KB Output is correct
2 Correct 94 ms 377968 KB Output is correct
3 Correct 90 ms 377904 KB Output is correct
4 Correct 89 ms 377940 KB Output is correct
5 Runtime error 466 ms 766096 KB Execution killed with signal 11
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 135 ms 377940 KB Output is correct
2 Correct 94 ms 377968 KB Output is correct
3 Correct 90 ms 377904 KB Output is correct
4 Correct 89 ms 377940 KB Output is correct
5 Runtime error 466 ms 766096 KB Execution killed with signal 11
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 107 ms 377760 KB Output is correct
2 Correct 94 ms 377776 KB Output is correct
3 Correct 94 ms 378100 KB Output is correct
4 Correct 89 ms 377884 KB Output is correct
5 Correct 92 ms 377972 KB Output is correct
6 Correct 90 ms 377936 KB Output is correct
7 Correct 91 ms 377888 KB Output is correct
8 Correct 89 ms 377956 KB Output is correct
9 Incorrect 90 ms 377940 KB Output isn't correct
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 107 ms 377760 KB Output is correct
2 Correct 94 ms 377776 KB Output is correct
3 Correct 94 ms 378100 KB Output is correct
4 Correct 89 ms 377884 KB Output is correct
5 Correct 92 ms 377972 KB Output is correct
6 Correct 90 ms 377936 KB Output is correct
7 Correct 91 ms 377888 KB Output is correct
8 Correct 89 ms 377956 KB Output is correct
9 Incorrect 90 ms 377940 KB Output isn't correct
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 107 ms 377760 KB Output is correct
2 Correct 94 ms 377776 KB Output is correct
3 Correct 94 ms 378100 KB Output is correct
4 Correct 89 ms 377884 KB Output is correct
5 Correct 92 ms 377972 KB Output is correct
6 Correct 90 ms 377936 KB Output is correct
7 Correct 91 ms 377888 KB Output is correct
8 Correct 89 ms 377956 KB Output is correct
9 Incorrect 90 ms 377940 KB Output isn't correct
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 402 ms 766316 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 135 ms 377940 KB Output is correct
2 Correct 94 ms 377968 KB Output is correct
3 Correct 90 ms 377904 KB Output is correct
4 Correct 89 ms 377940 KB Output is correct
5 Runtime error 466 ms 766096 KB Execution killed with signal 11
6 Halted 0 ms 0 KB -