Submission #69503295


Source Code Expand

#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll long long
#define pii pair<int, int>
#define fi first
#define se second

int main(){
	ios::sync_with_stdio(0); cin.tie(0);
	int t;
	cin>>t;
	while(t--){
		ll n, k, x;
		cin>>n>>k>>x;

		int a[n+5];
		priority_queue<pair<long double, ll>> pq;
		for(int i=1; i<=n; i++){
			cin>>a[i];
			pq.push({a[i], 1});
		}

		while(k){
			long double now;
			ll cnt;
			tie(now, cnt) = pq.top();
			pq.pop();

			if(cnt > k){
				pq.push({now, cnt-k});

				cnt = k;
				now /= 2.0;

				k -= cnt;
				pq.push({now, cnt*2});
			}
			else{
				k -= cnt;
				now /= 2.0;
				pq.push({now, cnt*2});
			}
		}

		ll now = 0;
		long double ans;
		while(now < x){
			now += pq.top().se;
			ans = pq.top().fi;
			pq.pop();
		}

		cout<<fixed<<setprecision(9)<<ans<<endl;
	}
	return 0;
}

Submission Info

Submission Time
Task E - Cut in Half
User takeonicky
Language C++ 20 (gcc 12.2)
Score 475
Code Size 897 Byte
Status AC
Exec Time 409 ms
Memory 7756 KiB

Compile Error

In file included from /usr/include/c++/12/istream:39,
                 from /usr/include/c++/12/sstream:38,
                 from /usr/include/c++/12/complex:45,
                 from /usr/include/c++/12/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/12/bits/stdc++.h:54,
                 from Main.cpp:1:
In member function ‘std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long double) [with _CharT = char; _Traits = std::char_traits<char>]’,
    inlined from ‘int main()’ at Main.cpp:54:33:
/usr/include/c++/12/ostream:233:25: warning: ‘ans’ may be used uninitialized [-Wmaybe-uninitialized]
  233 |       { return _M_insert(__f); }
      |                ~~~~~~~~~^~~~~
Main.cpp: In function ‘int main()’:
Main.cpp:47:29: note: ‘ans’ was declared here
   47 |                 long double ans;
      |                             ^~~

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 404 ms 7596 KiB
random_02.txt AC 187 ms 5356 KiB
random_03.txt AC 359 ms 7752 KiB
random_04.txt AC 199 ms 5280 KiB
random_05.txt AC 409 ms 7756 KiB
random_06.txt AC 287 ms 7540 KiB
random_07.txt AC 358 ms 7664 KiB
random_08.txt AC 295 ms 7524 KiB
random_09.txt AC 221 ms 3652 KiB
random_10.txt AC 216 ms 3824 KiB
random_11.txt AC 207 ms 3768 KiB
random_12.txt AC 201 ms 3856 KiB
random_13.txt AC 221 ms 3840 KiB
random_14.txt AC 215 ms 3848 KiB
random_15.txt AC 208 ms 3736 KiB
random_16.txt AC 198 ms 3804 KiB
random_17.txt AC 140 ms 7740 KiB
random_18.txt AC 142 ms 7504 KiB
random_19.txt AC 141 ms 7604 KiB
random_20.txt AC 134 ms 7600 KiB
random_21.txt AC 134 ms 7580 KiB
random_22.txt AC 134 ms 7584 KiB
random_23.txt AC 168 ms 7596 KiB
random_24.txt AC 169 ms 7680 KiB
random_25.txt AC 168 ms 7644 KiB
random_26.txt AC 157 ms 7676 KiB
random_27.txt AC 156 ms 7576 KiB
random_28.txt AC 144 ms 7508 KiB
random_29.txt AC 165 ms 7600 KiB
random_30.txt AC 152 ms 7632 KiB
random_31.txt AC 11 ms 7644 KiB
random_32.txt AC 2 ms 3704 KiB
random_33.txt AC 59 ms 3772 KiB
random_34.txt AC 58 ms 3788 KiB
random_35.txt AC 59 ms 3796 KiB
sample_01.txt AC 2 ms 3668 KiB