Submission #907628

# Submission time Handle Problem Language Result Execution time Memory
907628 2024-01-16T00:40:30 Z vjudge1 Let's Win the Election (JOI22_ho_t3) C++17
10 / 100
10 ms 504 KB
#include <bits/stdc++.h>
using namespace std;

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define F first
#define S second
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);
	int n;cin>>n;
	int k;cin>>k;
	vector<pair<pair<ll,ll>,int>> bya(n);
	rep(i,0,n)cin>>bya[i].F.F>>bya[i].F.S;
	sort(all(bya));
	rep(i,0,n)bya[i].S=i;
	vector<pair<pair<ll,ll>,int>> byb = bya;
	sort(all(byb), [&](auto a, auto b){
		if(a.F.S == -1) return false;
		if(b.F.S == -1) return true;
		return a.F.S < b.F.S;
	});
	while(sz(byb) && byb.back().F.S == -1) byb.pop_back();
	// for(auto p : bya) cout<< p.F.F<<' '<<p.F.S<<' '<<p.S<<endl;
	// cout<<endl;
	// for(auto p : byb) cout<< p.F.F<<' '<<p.F.S<<' '<<p.S<<endl;
	double fast = 1e18;
	rep(u,0,min(k,sz(byb))+1){
		double time = 0;
		set<int> have;
		rep(i,0,u){
			time += (double)byb[i].F.S/(1+i);
			have.insert(byb[i].S);
		}
		int need = k-u;
		rep(i,0,n){
			if(need==0) break;
			if(have.count(i)) continue;
			time += (double)bya[i].F.F/(u+1);
			need--;
		}
		fast = min(fast, time);
	}
	cout<<fixed<<setprecision(10)<<fast<<endl;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 4 ms 348 KB Output is correct
16 Correct 3 ms 348 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 9 ms 344 KB Output is correct
19 Correct 4 ms 344 KB Output is correct
20 Correct 2 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 0 ms 348 KB Output is correct
7 Correct 1 ms 504 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Incorrect 1 ms 344 KB Output isn't correct
10 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 0 ms 348 KB Output is correct
7 Correct 1 ms 504 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Incorrect 1 ms 344 KB Output isn't correct
10 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 0 ms 348 KB Output is correct
7 Correct 1 ms 504 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Incorrect 1 ms 344 KB Output isn't correct
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 10 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 4 ms 348 KB Output is correct
16 Correct 3 ms 348 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 9 ms 344 KB Output is correct
19 Correct 4 ms 344 KB Output is correct
20 Correct 2 ms 348 KB Output is correct
21 Correct 1 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 1 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 1 ms 504 KB Output is correct
28 Correct 1 ms 344 KB Output is correct
29 Incorrect 1 ms 344 KB Output isn't correct
30 Halted 0 ms 0 KB -