답안 #112989

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
112989 2019-05-23T02:10:02 Z CaroLinda 쌀 창고 (IOI11_ricehub) C++14
0 / 100
16 ms 1920 KB
#include <bits/stdc++.h>
#include "ricehub.h"
 
#define lp(i,a,b) for(int i = a ; i < b ; i++)
#define ll long long
#define pii pair<int,int>
#define ff first
#define ss second
#define pb push_back
#define mk make_pair
 
const int inf = 1e9 + 10 ;
const int MAXN = 1e5 + 10 ;
 
using namespace std ;
 
int l , r , x[MAXN] ;
ll b ;
int pref[MAXN] , suf[MAXN] ;
 
int m(int a , int b)
{ return (a+b)/2 ; }
 
ll c1(int a , int b)
{ return pref[b] - pref[a-1] - (b-a+1) * x[a] ; }
 
ll c2(int a , int b)
{ return suf[a] - suf[b+1] - (b-a+1) * (l-x[b]) ; }
 
bool test(int tam)
{
 
  int ini = 1 , fim = tam ;
 
  while( fim <= r )
  {
    int now = m(ini,fim) ;
    if( c1( ini , now ) + c2( now , fim ) <= b ) 
      return true ;
    ini ++ , fim++ ;
  }
  
  return false ;
 
}
 
int besthub(int R , int L , int X[] , ll B )
{
  b = B , r = R , l = L ;
  lp(i,1,r+1) x[i] = X[i-1] ;
 
  sort( x+1 , x+r+1 ) ;
 
  lp(i,1,r+1) pref[i] = pref[i-1] + x[i];
 
  for(int i = r ; i > 0 ; i-- ) suf[i] = suf[i+1] + L - x[i] ;
 
  int ini = 1 , fim = r , best = 1;
 
  while( ini <= fim )
  {
    if( test( m(ini,fim) ) )
    {
      best = m(ini,fim) ;
      ini = m(ini,fim) + 1 ;
    }
 
    else fim = m(ini,fim) - 1;
 
  }
 
  return best ;
 
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 356 KB Output is correct
3 Incorrect 2 ms 384 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 304 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 4 ms 384 KB Output is correct
8 Correct 2 ms 356 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Incorrect 2 ms 384 KB Output isn't correct
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Incorrect 2 ms 384 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 768 KB Output is correct
2 Correct 5 ms 640 KB Output is correct
3 Correct 15 ms 1920 KB Output is correct
4 Incorrect 16 ms 1912 KB Output isn't correct
5 Halted 0 ms 0 KB -