# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
722880 | 2023-04-13T04:18:21 Z | ktkerem | 쌀 창고 (IOI11_ricehub) | C++17 | 0 ms | 0 KB |
/*#pragma GCC target ("avx2") #pragma GCC optimize ("O3") #pragma GCC optimize("Ofast") #pragma GCC optimize ("unroll-loops") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")/**/ #include<bits/stdc++.h> #include "ricehub.h" typedef long long ll; typedef long double ld; typedef __int128 vll; typedef long long ftyp; typedef std::complex<ftyp> vec; #define llll std::pair<ll , ll> #define pb push_back #define fi first #define sec second #define cx real #define cy imag #define all(a) a.begin() , a.end() #define debug std::cout << "!!ALERT ALERT!!" << std::endl; const ll limit = 1e12+7; const ll sus = 2e5+5; std::mt19937 rng(std::chrono::steady_clock::now().time_since_epoch().count()); ll besthub(ll n , ll k , ll x[] ,ll cst){ std::sort(x , x+n); ll l = 1 , r = n; while(r > l){ ll md = (l + r + 1)/2; ll lsum = 0 , rsum = 0; for(ll i = 0;md/2>i;i++){ lsum += x[i]; } for(ll i = md/2+1;md>i;i++){ rsum += x[i]; } ll kd = (((x[md/2] * (md/2) - lsum) + (rsum - x[md/2] * ((md-1)/2))) <= cst?1:0); ll median = md/2; for(ll j = md;n>j;j++){ if(kd){ break; } rsum += x[j]; lsum += x[median]; median++; rsum -= x[median]; lsum -= x[j - md]; kd = (((x[median] * (md/2) - lsum) + (rsum - x[median] * ((md-1)/2))) <= cst?1:0); } if(kd){ l = md; } else{ r = md - 1; } } return r; } /*void solve(){ ll n , k;std::cin >> n >> k; ll ar[5] = {1 , 2 , 10 , 12 , 14}; std::cout << besthub(n , k , ar , 6) << "\n"; return; } int main(){ std::ios_base::sync_with_stdio(false);std::cin.tie(NULL); #ifndef ONLINE_JUDGE freopen("in.txt" , "r" , stdin); freopen("out.txt" , "w" , stdout); #endif ll t = 1; //std::cin >> t; while(t--){ solve(); } }*/