답안 #235811

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
235811 2020-05-30T02:30:18 Z Masterdan 쌀 창고 (IOI11_ricehub) C++14
100 / 100
28 ms 3064 KB
#include "ricehub.h"
#include <bits/stdc++.h>
#define MAX 1e9+7
#define PI 3.141592653589
#define pb push_back
#define mk make_pair
#define F  first
#define S  second
#define MIN -1
#define SMAX 1e18+7
#define all(a)  a.begin (), a.end ()
using namespace std;
typedef long long int ll;
typedef vector <int> vi;
typedef pair<int, int> ii;
typedef vector<ll> vll;
typedef double db;
int besthub(int n, int L, int X[], ll cash)
{
    vll v;
    for(int i=0;i<n;i++){
        v.pb(ll(X[i]));
    }
    //vi v1=v;
    //sort(all(v1));
   /* ll in=1, fin=cash+1;
    while(in!=fin){
        ll mid=(in+fin)/2;
        ll totalaux=0;
        for(int i=0;i<v1.size ();i++){
            ll aux=(abs(mid-v[i]));
                totalaux+=aux;

        }
        if(totalaux>cash)totalaux=0;
        int midfin=(mid+1+fin)/2;
        for(int i=0;i<v1.size ();i++){
            int aux=abs(midfin-v[i]);

        }
        int midin=(in+mid)/2;
    }*/
    ll in=0,fin=0;
    ll totalaux=0,mid=0,flag=1,total=1;
    while(fin<n){
        //if(fin>=n)break;
        if(totalaux>cash){
            totalaux=totalaux-(v[mid]-v[in]);in++;
            if(flag%2==1)mid++;
            flag--;
        }
        else{
            fin++;
            totalaux=totalaux+(v[fin]-v[mid]);total=max(total,flag);
            if(flag%2==1)mid++;
            flag++;
        }
    }
    return total;
}
/*

static int R, L;
static long long B;
static int X[MAX_R];
static int solution;

inline
void my_assert(int e) {if (!e) abort();}

static void read_input()
{
  int i;
  my_assert(3==scanf("%d %d %lld",&R,&L,&B));
  for(i=0; i<R; i++)
    my_assert(1==scanf("%d",&X[i]));
  my_assert(1==scanf("%d",&solution));
}

int main()
{
  int ans;
  read_input();
  ans = besthub(R,L,X,B);
  if(ans==solution)
    printf("Correct.\n");
  else
    printf("Incorrect.  Returned %d instead of %d.\n",ans,solution);

  return 0;
}*/
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 256 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 4 ms 256 KB Output is correct
4 Correct 5 ms 256 KB Output is correct
5 Correct 5 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 256 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Correct 4 ms 256 KB Output is correct
4 Correct 4 ms 256 KB Output is correct
5 Correct 5 ms 512 KB Output is correct
6 Correct 5 ms 256 KB Output is correct
7 Correct 4 ms 384 KB Output is correct
8 Correct 5 ms 256 KB Output is correct
9 Correct 4 ms 256 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 4 ms 256 KB Output is correct
12 Correct 4 ms 384 KB Output is correct
13 Correct 5 ms 256 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 5 ms 256 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 5 ms 256 KB Output is correct
18 Correct 5 ms 384 KB Output is correct
19 Correct 5 ms 384 KB Output is correct
20 Correct 5 ms 256 KB Output is correct
21 Correct 5 ms 384 KB Output is correct
22 Correct 5 ms 384 KB Output is correct
23 Correct 5 ms 384 KB Output is correct
24 Correct 5 ms 384 KB Output is correct
25 Correct 4 ms 384 KB Output is correct
26 Correct 5 ms 384 KB Output is correct
27 Correct 5 ms 384 KB Output is correct
28 Correct 5 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 256 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 5 ms 384 KB Output is correct
19 Correct 5 ms 384 KB Output is correct
20 Correct 5 ms 384 KB Output is correct
21 Correct 5 ms 512 KB Output is correct
22 Correct 6 ms 512 KB Output is correct
23 Correct 5 ms 512 KB Output is correct
24 Correct 5 ms 512 KB Output is correct
25 Correct 5 ms 512 KB Output is correct
26 Correct 6 ms 548 KB Output is correct
27 Correct 5 ms 512 KB Output is correct
28 Correct 5 ms 512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 768 KB Output is correct
2 Correct 9 ms 1024 KB Output is correct
3 Correct 22 ms 2936 KB Output is correct
4 Correct 22 ms 3064 KB Output is correct
5 Correct 12 ms 1532 KB Output is correct
6 Correct 12 ms 1532 KB Output is correct
7 Correct 20 ms 2680 KB Output is correct
8 Correct 28 ms 2672 KB Output is correct
9 Correct 12 ms 1532 KB Output is correct
10 Correct 12 ms 1404 KB Output is correct
11 Correct 26 ms 2936 KB Output is correct
12 Correct 24 ms 2936 KB Output is correct
13 Correct 13 ms 1532 KB Output is correct
14 Correct 13 ms 1532 KB Output is correct
15 Correct 19 ms 2680 KB Output is correct
16 Correct 19 ms 2552 KB Output is correct
17 Correct 21 ms 2808 KB Output is correct
18 Correct 23 ms 2808 KB Output is correct
19 Correct 23 ms 2800 KB Output is correct
20 Correct 23 ms 2808 KB Output is correct