Submission #529417

# Submission time Handle Problem Language Result Execution time Memory
529417 2022-02-23T02:01:38 Z fhvirus Let's Win the Election (JOI22_ho_t3) C++17
10 / 100
7 ms 332 KB
#include <bits/stdc++.h>
using namespace std;
typedef int64_t ll; typedef pair<int, int> pii;
#define pb emplace_back
#define AI(x) begin(x),end(x)
#define ff first
#define ss second
#ifdef OWO
#define debug(args...) LKJ("\033[0;32m[ " + string(#args) + " ]\033[0m", args)
template<class I> void LKJ(I&&x) { cerr << x << endl; }
template<class I, class...T> void LKJ(I&&x, T&&...t) { cerr << x << ", "; LKJ(t...); }
template<class I> void OI(I a, I b) { while (a < b) cerr << *a << " \n"[next(a) == b]; }
#else
#define debug(...) 0
#define OI(...) 0
#endif

signed main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

	int N; cin >> N;
	int K; cin >> K;
	int has_co = 0;
	vector<int> A(N + 1), B(N + 1);
	for (int i = 1; i <= N; ++i) {
		cin >> A[i] >> B[i];
		has_co += (B[i] != -1);
		if (B[i] == -1) B[i] = 1'000'000'000;
	}

	vector<int> co(N);
	iota(AI(co), 1);
	sort(AI(co), [&](int u, int v) {
		if (B[u] != B[v])
			return B[u] < B[v];
		return A[u] > A[v];
	});

	double ans = 1e18;
	for (int c = 0; c <= has_co; ++c) {
		double tmp = 0;
		for (int i = 0; i < c; ++i)
			tmp += B[co[i]] / (double) (i + 1);
		vector<int> oth;
		for (int i = c; i < N; ++i)
			oth.pb(co[i]);
		sort(AI(oth), [&](int u, int v) {
			return A[u] < A[v];
		});
		double mul = c + 1;
		for (int i = 0; i + c < K; ++i) {
			tmp += A[oth[i]] / mul;
			if (A[oth[i]] == B[oth[i]])
				mul += 1;
		}
		debug(c, tmp);
		ans = min(ans, tmp);
	}
	cout << setprecision(10) << fixed << ans << '\n';

	return 0;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:14:20: warning: statement has no effect [-Wunused-value]
   14 | #define debug(...) 0
      |                    ^
Main.cpp:56:3: note: in expansion of macro 'debug'
   56 |   debug(c, tmp);
      |   ^~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 1 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
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 1 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 3 ms 204 KB Output is correct
13 Correct 4 ms 324 KB Output is correct
14 Correct 2 ms 204 KB Output is correct
15 Correct 3 ms 204 KB Output is correct
16 Correct 4 ms 204 KB Output is correct
17 Correct 2 ms 204 KB Output is correct
18 Correct 3 ms 204 KB Output is correct
19 Correct 4 ms 332 KB Output is correct
20 Correct 3 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 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 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Incorrect 1 ms 204 KB Output isn't correct
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 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 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Incorrect 1 ms 204 KB Output isn't correct
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 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 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Incorrect 1 ms 204 KB Output isn't correct
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 328 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 1 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 3 ms 204 KB Output is correct
13 Correct 4 ms 324 KB Output is correct
14 Correct 2 ms 204 KB Output is correct
15 Correct 3 ms 204 KB Output is correct
16 Correct 4 ms 204 KB Output is correct
17 Correct 2 ms 204 KB Output is correct
18 Correct 3 ms 204 KB Output is correct
19 Correct 4 ms 332 KB Output is correct
20 Correct 3 ms 204 KB Output is correct
21 Correct 0 ms 204 KB Output is correct
22 Correct 0 ms 204 KB Output is correct
23 Correct 0 ms 204 KB Output is correct
24 Correct 0 ms 204 KB Output is correct
25 Correct 0 ms 204 KB Output is correct
26 Correct 0 ms 204 KB Output is correct
27 Correct 0 ms 204 KB Output is correct
28 Correct 0 ms 204 KB Output is correct
29 Incorrect 1 ms 204 KB Output isn't correct
30 Halted 0 ms 0 KB -