Submission #928237

# Submission time Handle Problem Language Result Execution time Memory
928237 2024-02-16T05:42:36 Z pcc Let's Win the Election (JOI22_ho_t3) C++14
10 / 100
8 ms 456 KB
#include <bits/stdc++.h>
using namespace std;


#define ll long long
#define pll pair<ll,ll>
#define fs first
#define sc second
#define ld double

const ll inf = 1e12;
const ll mxn = 550;
pll arr[mxn];
ll N,K;
bitset<mxn> done;

inline ld f(ll cnt){
	done.reset();
	vector<pll> v;
	for(int i= 0;i<N;i++)v.push_back({arr[i].sc,i});
	sort(v.begin(),v.end());
	ld re = 0,c = 1;
	for(int i = 0;i<cnt;i++){
		re += v[i].fs/c;
		c+=1;
		done[v[i].sc] = true;
	}
	ll now = cnt;
	for(int i = 0;i<N;i++){
		if(now>=K)break;
		if(done[i])continue;
		re += arr[i].fs/c;
		now++;
	}
	return re;
}

int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>N>>K;
	for(int i = 0;i<N;i++)cin>>arr[i].fs>>arr[i].sc,arr[i].sc = (arr[i].sc == -1?inf:arr[i].sc);
	sort(arr,arr+N);
	ld ans = inf;
	for(int i = 0;i<=K;i++)ans = min(ans,f(i));
	cout<<fixed<<setprecision(20)<<ans;
}
# Verdict Execution time Memory Grader output
1 Correct 1 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 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 2 ms 348 KB Output is correct
7 Correct 3 ms 348 KB Output is correct
8 Correct 4 ms 348 KB Output is correct
9 Correct 6 ms 456 KB Output is correct
10 Correct 4 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 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 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 2 ms 348 KB Output is correct
7 Correct 3 ms 348 KB Output is correct
8 Correct 4 ms 348 KB Output is correct
9 Correct 6 ms 456 KB Output is correct
10 Correct 4 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 2 ms 348 KB Output is correct
13 Correct 3 ms 348 KB Output is correct
14 Correct 2 ms 348 KB Output is correct
15 Correct 4 ms 348 KB Output is correct
16 Correct 5 ms 348 KB Output is correct
17 Correct 6 ms 348 KB Output is correct
18 Correct 5 ms 348 KB Output is correct
19 Correct 8 ms 348 KB Output is correct
20 Correct 7 ms 348 KB Output is correct
# Verdict Execution time Memory 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 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 344 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 -
# Verdict Execution time Memory 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 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 344 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 -
# Verdict Execution time Memory 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 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 344 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 -
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 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 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 2 ms 348 KB Output is correct
7 Correct 3 ms 348 KB Output is correct
8 Correct 4 ms 348 KB Output is correct
9 Correct 6 ms 456 KB Output is correct
10 Correct 4 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 2 ms 348 KB Output is correct
13 Correct 3 ms 348 KB Output is correct
14 Correct 2 ms 348 KB Output is correct
15 Correct 4 ms 348 KB Output is correct
16 Correct 5 ms 348 KB Output is correct
17 Correct 6 ms 348 KB Output is correct
18 Correct 5 ms 348 KB Output is correct
19 Correct 8 ms 348 KB Output is correct
20 Correct 7 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 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 1 ms 344 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 -