Submission #69491099


Source Code Expand

/* Code By WCM */
/*
Date:
大致思路:
复杂度:
期望得分:
*/
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <ctime>
#include <iomanip>
#include <vector>
#include <queue>
#include <map>
#define int long long
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(),x.end()

using namespace std;

inline int read();
void write(int);
void writeln(int);

typedef double db;
const int N = 1e5 + 5;
int T, n, k, X;
db a[N];

signed main() {

//	freopen(".in", "r", stdin);
//	freopen(".out", "w", stdout);
	
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	cin >> T;
	while(T--) {
		cin >> n >> k >> X;
		priority_queue <db> q;
		map <db, int> mp;
		for(int i = 0; i < n; i++) cin >> a[i], mp[a[i]]++, q.push(a[i]);
		while(k > 0) {
			if(q.empty()) break;
			db x = q.top();
			while(mp.find(x) == mp.end() || mp[x] == 0) {
				q.pop();
				if(q.empty()) break;
				x = q.top();
			}
			int ct = mp[x];
			if(ct <= k) mp[x] = 0, mp[x / 2.0] += ct * 2, q.push(x / 2.0), k -= ct;
			else mp[x] -= k, mp[x / 2.0] += k * 2, k = 0;
		}
		vector <pair <db, int> > Q;
		for(auto &x : mp) if(x.S > 0) Q.pb({x.F, x.S});
		sort(all(Q)), reverse(all(Q));
		int now = 0; db ans = 0.0;
		for(auto &x : Q) {
			if(now + x.S >= X) { ans = x.F; break; }
			now += x.S;
		}
		cout << fixed << setprecision(20) << ans << '\n';
	}
	
//	printf("\nThe time used: ");
//	printf("%.2lfs",(double)clock()/CLOCKS_PER_SEC);

	return 0;

}

inline int read() {
	int res = 0, f = 1;
	char ch = getchar();
	while( !(ch >= '0' && ch <= '9') ) {
		if(ch == '-') f = -1;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9') {
		res = (res << 1) + (res << 3) + (ch ^ 48);
		ch = getchar();
	}
	return res * f;
}

void write(int x) {
	static int sta[35];
	int top = 0;
	do {
		sta[top++] = x % 10;
		x /= 10;
	} while(x);
	while(top) putchar(sta[--top] ^ 48);
}

void writeln(int x) {
	write(x);
	putchar('\n');
}

Submission Info

Submission Time
Task E - Cut in Half
User WZwangchongming
Language C++ 20 (gcc 12.2)
Score 475
Code Size 2054 Byte
Status AC
Exec Time 1145 ms
Memory 93448 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 475 / 475
Status
AC × 1
AC × 36
Set Name Test Cases
Sample sample_01.txt
All random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, random_23.txt, random_24.txt, random_25.txt, random_26.txt, random_27.txt, random_28.txt, random_29.txt, random_30.txt, random_31.txt, random_32.txt, random_33.txt, random_34.txt, random_35.txt, sample_01.txt
Case Name Status Exec Time Memory
random_01.txt AC 1130 ms 93440 KiB
random_02.txt AC 687 ms 58884 KiB
random_03.txt AC 992 ms 85024 KiB
random_04.txt AC 690 ms 60256 KiB
random_05.txt AC 1129 ms 93448 KiB
random_06.txt AC 882 ms 74960 KiB
random_07.txt AC 1006 ms 85088 KiB
random_08.txt AC 868 ms 75072 KiB
random_09.txt AC 1140 ms 5120 KiB
random_10.txt AC 1006 ms 5004 KiB
random_11.txt AC 1046 ms 5084 KiB
random_12.txt AC 934 ms 4832 KiB
random_13.txt AC 1145 ms 5020 KiB
random_14.txt AC 1028 ms 5152 KiB
random_15.txt AC 1038 ms 5068 KiB
random_16.txt AC 922 ms 4856 KiB
random_17.txt AC 16 ms 5080 KiB
random_18.txt AC 16 ms 4996 KiB
random_19.txt AC 16 ms 5148 KiB
random_20.txt AC 16 ms 5076 KiB
random_21.txt AC 16 ms 5076 KiB
random_22.txt AC 15 ms 5052 KiB
random_23.txt AC 22 ms 4992 KiB
random_24.txt AC 21 ms 4996 KiB
random_25.txt AC 22 ms 5076 KiB
random_26.txt AC 22 ms 5056 KiB
random_27.txt AC 22 ms 5068 KiB
random_28.txt AC 21 ms 5120 KiB
random_29.txt AC 847 ms 78812 KiB
random_30.txt AC 842 ms 78704 KiB
random_31.txt AC 14 ms 5072 KiB
random_32.txt AC 1 ms 3816 KiB
random_33.txt AC 83 ms 3692 KiB
random_34.txt AC 85 ms 3632 KiB
random_35.txt AC 104 ms 3800 KiB
sample_01.txt AC 1 ms 3748 KiB