Submission #923792

# Submission time Handle Problem Language Result Execution time Memory
923792 2024-02-07T18:58:36 Z OAleksa Let's Win the Election (JOI22_ho_t3) C++14
10 / 100
427 ms 5208 KB
#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define int long long
const int N = 550;
const int inf = 1e18;
int n, x;
pair<int, int> a[N];
double dp1[N][N], dp2[N][N];
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int tt = 1;
  //cin >> tt;
  while (tt--) {
  	cin >> n >> x;
  	for (int i = 1;i <= n;i++) {
  		cin >> a[i].f >> a[i].s;
  		if (a[i].s == -1)
  			a[i].s = inf;
  	}
  	sort(a + 1, a + n + 1, [&](pair<int, int> x, pair<int, int> y) {
  		if (x.s == y.s)
  			return x.f > y.f;
  		return x.s < y.s;
  	});
  	for (int i = 0;i <= n;i++) {
  		for (int j = 0;j <= n;j++) {
  			dp1[i][j] = inf;
  		}
  	}
		dp1[0][1] = 0;
  	//prvih i, dobio sam j glasova, k ljudi je samnom
  	for (int i = 1;i <= n;i++) {
  		for (int j = 1;j <= n;j++) {
  			for (int k = 1;k <= n;k++) {
  				dp2[j][k] = dp1[j][k];
  				dp2[j][k] = min(dp2[j][k], dp1[j - 1][k] + (double)a[i].f / k);
  				dp2[j][k] = min(dp2[j][k], dp1[j - 1][k - 1] + (double)a[i].s / (k - 1));
  			}
  		}
  		for (int j = 1;j <= n;j++) {
  			for (int k = 1;k <= n;k++)
  				dp1[j][k] = dp2[j][k];
  		}
  	}
  	double ans = inf;
  	for (int i = 1;i <= n;i++)
  		ans = min(ans, dp1[x][i]);
  	cout << fixed << setprecision(15) << ans;
  }
  return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 426 ms 4984 KB Output is correct
6 Correct 424 ms 4952 KB Output is correct
7 Correct 424 ms 5204 KB Output is correct
8 Correct 425 ms 4956 KB Output is correct
9 Correct 424 ms 4952 KB Output is correct
10 Correct 427 ms 5208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 426 ms 4984 KB Output is correct
6 Correct 424 ms 4952 KB Output is correct
7 Correct 424 ms 5204 KB Output is correct
8 Correct 425 ms 4956 KB Output is correct
9 Correct 424 ms 4952 KB Output is correct
10 Correct 427 ms 5208 KB Output is correct
11 Correct 0 ms 2396 KB Output is correct
12 Correct 425 ms 4956 KB Output is correct
13 Correct 424 ms 5204 KB Output is correct
14 Correct 422 ms 4956 KB Output is correct
15 Correct 426 ms 4976 KB Output is correct
16 Correct 424 ms 4976 KB Output is correct
17 Correct 425 ms 4968 KB Output is correct
18 Correct 427 ms 5200 KB Output is correct
19 Correct 426 ms 4952 KB Output is correct
20 Correct 425 ms 4968 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Incorrect 0 ms 2396 KB Output isn't correct
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Incorrect 0 ms 2396 KB Output isn't correct
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Incorrect 0 ms 2396 KB Output isn't correct
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 424 ms 4968 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 426 ms 4984 KB Output is correct
6 Correct 424 ms 4952 KB Output is correct
7 Correct 424 ms 5204 KB Output is correct
8 Correct 425 ms 4956 KB Output is correct
9 Correct 424 ms 4952 KB Output is correct
10 Correct 427 ms 5208 KB Output is correct
11 Correct 0 ms 2396 KB Output is correct
12 Correct 425 ms 4956 KB Output is correct
13 Correct 424 ms 5204 KB Output is correct
14 Correct 422 ms 4956 KB Output is correct
15 Correct 426 ms 4976 KB Output is correct
16 Correct 424 ms 4976 KB Output is correct
17 Correct 425 ms 4968 KB Output is correct
18 Correct 427 ms 5200 KB Output is correct
19 Correct 426 ms 4952 KB Output is correct
20 Correct 425 ms 4968 KB Output is correct
21 Correct 1 ms 2396 KB Output is correct
22 Correct 1 ms 2396 KB Output is correct
23 Correct 0 ms 2396 KB Output is correct
24 Correct 1 ms 2396 KB Output is correct
25 Correct 1 ms 2396 KB Output is correct
26 Correct 1 ms 2396 KB Output is correct
27 Correct 1 ms 2396 KB Output is correct
28 Correct 1 ms 2396 KB Output is correct
29 Incorrect 0 ms 2396 KB Output isn't correct
30 Halted 0 ms 0 KB -