답안 #722881

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
722881 2023-04-13T04:18:59 Z ktkerem 쌀 창고 (IOI11_ricehub) C++17
100 / 100
15 ms 1748 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());
int besthub(int n , int k , int 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();
  }
}*/

Compilation message

ricehub.cpp:5:78: warning: "/*" within comment [-Wcomment]
    5 | #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")/**/
      |
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 316 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 312 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 308 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 312 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 312 KB Output is correct
17 Correct 1 ms 308 KB Output is correct
18 Correct 1 ms 308 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 308 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 308 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 308 KB Output is correct
3 Correct 1 ms 320 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 308 KB Output is correct
10 Correct 1 ms 308 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 312 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 312 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 328 KB Output is correct
25 Correct 1 ms 320 KB Output is correct
26 Correct 2 ms 352 KB Output is correct
27 Correct 2 ms 352 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 468 KB Output is correct
2 Correct 3 ms 596 KB Output is correct
3 Correct 14 ms 1728 KB Output is correct
4 Correct 15 ms 1704 KB Output is correct
5 Correct 7 ms 732 KB Output is correct
6 Correct 9 ms 844 KB Output is correct
7 Correct 13 ms 1384 KB Output is correct
8 Correct 12 ms 1364 KB Output is correct
9 Correct 6 ms 724 KB Output is correct
10 Correct 6 ms 724 KB Output is correct
11 Correct 13 ms 1748 KB Output is correct
12 Correct 13 ms 1740 KB Output is correct
13 Correct 7 ms 852 KB Output is correct
14 Correct 7 ms 852 KB Output is correct
15 Correct 10 ms 1348 KB Output is correct
16 Correct 14 ms 1356 KB Output is correct
17 Correct 12 ms 1576 KB Output is correct
18 Correct 13 ms 1552 KB Output is correct
19 Correct 13 ms 1600 KB Output is correct
20 Correct 13 ms 1620 KB Output is correct