답안 #923784

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
923784 2024-02-07T18:38:59 Z OAleksa Let's Win the Election (JOI22_ho_t3) C++14
10 / 100
429 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) {
  		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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2804 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 425 ms 4972 KB Output is correct
6 Correct 424 ms 4956 KB Output is correct
7 Correct 423 ms 4956 KB Output is correct
8 Correct 424 ms 4956 KB Output is correct
9 Correct 426 ms 4956 KB Output is correct
10 Correct 425 ms 4952 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2804 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 425 ms 4972 KB Output is correct
6 Correct 424 ms 4956 KB Output is correct
7 Correct 423 ms 4956 KB Output is correct
8 Correct 424 ms 4956 KB Output is correct
9 Correct 426 ms 4956 KB Output is correct
10 Correct 425 ms 4952 KB Output is correct
11 Correct 1 ms 2392 KB Output is correct
12 Correct 425 ms 4976 KB Output is correct
13 Correct 423 ms 4956 KB Output is correct
14 Correct 424 ms 4972 KB Output is correct
15 Correct 423 ms 4972 KB Output is correct
16 Correct 423 ms 4952 KB Output is correct
17 Correct 426 ms 4984 KB Output is correct
18 Correct 427 ms 4956 KB Output is correct
19 Correct 429 ms 5208 KB Output is correct
20 Correct 425 ms 4972 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 2 ms 2392 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 0 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 1 ms 2396 KB Output isn't correct
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 2 ms 2392 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 0 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 1 ms 2396 KB Output isn't correct
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 2 ms 2392 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 0 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 1 ms 2396 KB Output isn't correct
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 427 ms 4976 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2804 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 425 ms 4972 KB Output is correct
6 Correct 424 ms 4956 KB Output is correct
7 Correct 423 ms 4956 KB Output is correct
8 Correct 424 ms 4956 KB Output is correct
9 Correct 426 ms 4956 KB Output is correct
10 Correct 425 ms 4952 KB Output is correct
11 Correct 1 ms 2392 KB Output is correct
12 Correct 425 ms 4976 KB Output is correct
13 Correct 423 ms 4956 KB Output is correct
14 Correct 424 ms 4972 KB Output is correct
15 Correct 423 ms 4972 KB Output is correct
16 Correct 423 ms 4952 KB Output is correct
17 Correct 426 ms 4984 KB Output is correct
18 Correct 427 ms 4956 KB Output is correct
19 Correct 429 ms 5208 KB Output is correct
20 Correct 425 ms 4972 KB Output is correct
21 Correct 1 ms 2396 KB Output is correct
22 Correct 2 ms 2392 KB Output is correct
23 Correct 1 ms 2396 KB Output is correct
24 Correct 0 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 1 ms 2396 KB Output isn't correct
30 Halted 0 ms 0 KB -