Submission #527688

# Submission time Handle Problem Language Result Execution time Memory
527688 2022-02-18T03:05:53 Z 8e7 Let's Win the Election (JOI22_ho_t3) C++17
23 / 100
2500 ms 324 KB
//Challenge: Accepted
#include <bits/stdc++.h>
using namespace std;
#ifdef zisk
void debug(){cout << endl;}
template<class T, class ... U> void debug(T a, U ... b){cout << a << " ", debug(b...);}
template<class T> void pary(T l, T r) {
	while (l != r) cout << *l << " ", l++;
	cout << endl;
}
#else
#define debug(...) 0
#define pary(...) 0
#endif
#define ll long long
#define maxn 505
#define pii pair<int, int>
#define ff first
#define ss second
#define io ios_base::sync_with_stdio(0);cin.tie(0);
pii a[maxn];
int main() {
	io
	int n, k;
	cin >> n >> k;

	for (int i = 0;i < n;i++) {
		cin >> a[i].ff >> a[i].ss; 	
		if (a[i].ss == -1) a[i].ss = 1<<30;
	}
	/*
	sort(a, a + n, [&] (pii x, pii y){return x.ss < y.ss;});
	double cur = 0, ans = 1e9;
	for (int i = 0;i < k;i++) {
		vector<pii> b;
		for (int j = n-1;j >= i;j--) {
			b.push_back(a[j]);
		}
		sort(b.begin(), b.end());
		double tmp = cur;
		for (int j = 0;j < k - i;j++) {
			tmp += (double)b[j].ff / (i + 1);	
		}
		//debug(i, cur, tmp);
		ans = min(ans, tmp);
		cur += (double)a[i].ss / (i+1);
	}
	ans = min(ans, cur);
	*/
	double ans = 1e9;
	sort(a, a + n);
	for (int i = 0;i < (1<<n);i++) {
		double val = 0;
		vector<int> tmp;
		for (int j = 0;j < n;j++) {
			if (i & (1<<j)) {
				tmp.push_back(a[j].ss);
			}
		}
		sort(tmp.begin(), tmp.end());
		int cnt = tmp.size(), ts = tmp.size();
		for (int j = 0;j < ts;j++) {
			val += (double)tmp[j] / (j + 1);
		}
		for (int j = 0;j < n;j++) {
			if (!(i & (1<<j))) {
				cnt++;
				val += (double)a[j].ff / (ts + 1);
			}
			if (cnt >= k) break;
		}
		ans = min(ans, val);
	}
	cout << fixed << setprecision(10) << ans << "\n";
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 1989 ms 300 KB Output is correct
6 Correct 1977 ms 204 KB Output is correct
7 Correct 2220 ms 304 KB Output is correct
8 Correct 2469 ms 324 KB Output is correct
9 Execution timed out 2590 ms 204 KB Time limit exceeded
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 1989 ms 300 KB Output is correct
6 Correct 1977 ms 204 KB Output is correct
7 Correct 2220 ms 304 KB Output is correct
8 Correct 2469 ms 324 KB Output is correct
9 Execution timed out 2590 ms 204 KB Time limit exceeded
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 1 ms 220 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 1 ms 220 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 296 ms 296 KB Output is correct
17 Correct 278 ms 296 KB Output is correct
18 Correct 277 ms 292 KB Output is correct
19 Correct 306 ms 204 KB Output is correct
20 Correct 294 ms 292 KB Output is correct
21 Correct 276 ms 324 KB Output is correct
22 Correct 326 ms 204 KB Output is correct
23 Correct 310 ms 324 KB Output is correct
24 Correct 298 ms 204 KB Output is correct
25 Correct 332 ms 304 KB Output is correct
26 Correct 335 ms 288 KB Output is correct
27 Correct 303 ms 288 KB Output is correct
28 Correct 318 ms 288 KB Output is correct
29 Correct 305 ms 296 KB Output is correct
30 Correct 318 ms 292 KB Output is correct
31 Correct 313 ms 288 KB Output is correct
32 Correct 298 ms 288 KB Output is correct
33 Correct 299 ms 204 KB Output is correct
34 Correct 279 ms 292 KB Output is correct
35 Correct 294 ms 204 KB Output is correct
36 Correct 269 ms 288 KB Output is correct
37 Correct 262 ms 292 KB Output is correct
38 Correct 263 ms 204 KB Output is correct
39 Correct 252 ms 204 KB Output is correct
40 Correct 242 ms 288 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 1 ms 220 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 296 ms 296 KB Output is correct
17 Correct 278 ms 296 KB Output is correct
18 Correct 277 ms 292 KB Output is correct
19 Correct 306 ms 204 KB Output is correct
20 Correct 294 ms 292 KB Output is correct
21 Correct 276 ms 324 KB Output is correct
22 Correct 326 ms 204 KB Output is correct
23 Correct 310 ms 324 KB Output is correct
24 Correct 298 ms 204 KB Output is correct
25 Correct 332 ms 304 KB Output is correct
26 Correct 335 ms 288 KB Output is correct
27 Correct 303 ms 288 KB Output is correct
28 Correct 318 ms 288 KB Output is correct
29 Correct 305 ms 296 KB Output is correct
30 Correct 318 ms 292 KB Output is correct
31 Correct 313 ms 288 KB Output is correct
32 Correct 298 ms 288 KB Output is correct
33 Correct 299 ms 204 KB Output is correct
34 Correct 279 ms 292 KB Output is correct
35 Correct 294 ms 204 KB Output is correct
36 Correct 269 ms 288 KB Output is correct
37 Correct 262 ms 292 KB Output is correct
38 Correct 263 ms 204 KB Output is correct
39 Correct 252 ms 204 KB Output is correct
40 Correct 242 ms 288 KB Output is correct
41 Incorrect 0 ms 204 KB Output isn't correct
42 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2583 ms 204 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 1989 ms 300 KB Output is correct
6 Correct 1977 ms 204 KB Output is correct
7 Correct 2220 ms 304 KB Output is correct
8 Correct 2469 ms 324 KB Output is correct
9 Execution timed out 2590 ms 204 KB Time limit exceeded
10 Halted 0 ms 0 KB -