답안 #224630

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
224630 2020-04-18T14:14:27 Z DanerZein 쌀 창고 (IOI11_ricehub) C++14
0 / 100
1000 ms 860 KB
#include "ricehub.h"
#include <bits/stdc++.h>

#define MAX_R  1000000

using namespace std;
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();}

int besthub(int R,int L,int X[], long long B){
  // cout<<"a"<<endl;
  long long ma=-1;
  for(int i=0;i<R;i++){
    for(int j=i;j<R;j++){
      // cout<<i<<" "<<j<<endl;
      vector<int>rp;
      for(int k=i;k<=j;k++){
	rp.push_back(X[k]);
      }
      int mi=(i+j)/2;
      mi=X[mi];
      //  cout<<i<<" "<<j<<endl;
      bool sw=0;
      long long b=B;
      for(int k=0;k<rp.size();k++){
	if(b<=0){
	  sw=1;
	  break;
	}
	b-=abs(mi-rp[k]);
	//c++;
      }
      if(sw==0){
	//	cout<<i<<" "<<j<<" "<<rp.size()<<endl;
	long long tam=rp.size();
	ma=max(ma,tam);
      }
    }
  }
  return ma;
}/*
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 R,L,B,X[100];
  cin>>R>>L>>B;
  for(int i=0;i<R;i++){
    int a;
    cin>>a;
    X[i]=a;
  }
  cout<<besthub(R,L,X,B)<<endl;
}
 */

Compilation message

ricehub.cpp: In function 'int besthub(int, int, int*, long long int)':
ricehub.cpp:30:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
       for(int k=0;k<rp.size();k++){
                   ~^~~~~~~~~~
ricehub.cpp: At global scope:
ricehub.cpp:10:12: warning: 'solution' defined but not used [-Wunused-variable]
 static int solution;
            ^~~~~~~~
ricehub.cpp:9:12: warning: 'X' defined but not used [-Wunused-variable]
 static int X[MAX_R];
            ^
ricehub.cpp:8:18: warning: 'B' defined but not used [-Wunused-variable]
 static long long B;
                  ^
ricehub.cpp:7:15: warning: 'L' defined but not used [-Wunused-variable]
 static int R, L;
               ^
ricehub.cpp:7:12: warning: 'R' defined but not used [-Wunused-variable]
 static int R, L;
            ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 12 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1093 ms 860 KB Time limit exceeded
2 Halted 0 ms 0 KB -