Submission #887391

# Submission time Handle Problem Language Result Execution time Memory
887391 2023-12-14T11:45:13 Z dubabuba Let's Win the Election (JOI22_ho_t3) C++14
0 / 100
441 ms 1048580 KB
#include <bits/stdc++.h>
using namespace std;

template<typename T>
void ono_min(T &MIN, T CMP) { if(CMP < MIN) MIN = CMP; }

template<typename T>
void ono_max(T &MAX, T CMP) { if(CMP > MAX) MAX = CMP; }

const int mxn = 550;
int n, m, a[mxn], b[mxn];

double dp[mxn][mxn][mxn];
double solve(int help) {
	// cout << "help: " << help << '\n';
	for(int i = 0; i < mxn; i++)
	for(int j = 0; j < mxn; j++)
	for(int k = 0; k < mxn; k++)
		dp[i][j][k] = 1e9;

	dp[0][0][0] = 0.0;
	for(int i = 0; i < n; i++)
	for(int j = 0; j < n && j < m; j++)
	for(int k = 0; k <= j && k < help; k++) {
		ono_min(dp[i + 1][j][k], dp[i][j][k]);
		ono_min(dp[i + 1][j + 1][k], dp[i][j][k] + 1.0 * a[i] / (1.0 + k));
		if(b[i] != -1)
			ono_min(dp[i + 1][j + 1][k + 1], dp[i][j][k] + 1.0 * b[i] / (1.0 + k));
	}
	return dp[n][m][help];
}

int main() {
	cin >> n >> m;
	for(int i = 1; i <= n; i++)
		cin >> a[i] >> b[i];

	double ans = 1e9;
	for(int help = 0; help <= n; help++)
		ono_min(ans, solve(help));
	cout << ans << '\n';
	return 0;
}
# Verdict Execution time Memory Grader output
1 Runtime error 441 ms 1048576 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 441 ms 1048576 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 359 ms 1048580 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 359 ms 1048580 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 359 ms 1048580 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 356 ms 1048576 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 441 ms 1048576 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -