답안 #923819

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
923819 2024-02-07T21:04:08 Z OAleksa Let's Win the Election (JOI22_ho_t3) C++14
10 / 100
4 ms 600 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, k;
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 >> k;
  	vector<int> tm;
  	for (int i = 1;i <= n;i++) {
  		cin >> a[i].f >> a[i].s;
  		tm.push_back(a[i].f);
  		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;
  	});
  	sort(tm.begin(), tm.end());
		double ans = 0;
  	for (int i = 0;i < k;i++)
  		ans += tm[i];
		double t = 0;
  	for (int i = 2;i <= k + 1;i++) {
  		t += (double)a[i - 1].s / (i - 1);
  		vector<int> x;
  		for (int j = i;j <= n;j++) 
  			x.push_back(a[j].f);
  		sort(x.begin(), x.end());
  		double res = t;
  		for (int j = 0;j < k - i + 1;j++) {
  			res += (double)x[j] / i;
  		}
  		ans = min(ans, res);
  	}
  	cout << fixed << setprecision(15) << ans;
  }
  return 0;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:33:4: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   33 |    for (int i = 0;i < k;i++)
      |    ^~~
Main.cpp:35:3: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   35 |   double t = 0;
      |   ^~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 2 ms 344 KB Output is correct
9 Correct 2 ms 348 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 2 ms 344 KB Output is correct
9 Correct 2 ms 348 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 2 ms 344 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 2 ms 344 KB Output is correct
16 Correct 3 ms 348 KB Output is correct
17 Correct 2 ms 348 KB Output is correct
18 Correct 2 ms 344 KB Output is correct
19 Correct 3 ms 348 KB Output is correct
20 Correct 2 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 600 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Incorrect 0 ms 348 KB Output isn't correct
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 600 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Incorrect 0 ms 348 KB Output isn't correct
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 600 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Incorrect 0 ms 348 KB Output isn't correct
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 2 ms 344 KB Output is correct
9 Correct 2 ms 348 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 2 ms 344 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 2 ms 344 KB Output is correct
16 Correct 3 ms 348 KB Output is correct
17 Correct 2 ms 348 KB Output is correct
18 Correct 2 ms 344 KB Output is correct
19 Correct 3 ms 348 KB Output is correct
20 Correct 2 ms 348 KB Output is correct
21 Correct 0 ms 600 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Incorrect 0 ms 348 KB Output isn't correct
30 Halted 0 ms 0 KB -