답안 #224652

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

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));
}
using namespace std;
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++){
	
	b-=abs(mi-rp[k]);
	if(b<0){
	  sw=1;
	  break;
	}
	//c++;
      }
      if(sw==0){
	//	cout<<i<<" "<<j<<" "<<rp.size()<<endl;
	long long tam=rp.size();
	ma=max(ma,tam);
      }
    }
  }
  return ma;
}

/*
int main()
{
  int ans;
  read_input();
  // cout<<"a"<<endl;
  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;
}
*/

Compilation message

ricehub.cpp: In function 'int besthub(int, int, int*, long long int)':
ricehub.cpp:37: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:13:13: warning: 'void read_input()' defined but not used [-Wunused-function]
 static void read_input()
             ^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 6 ms 384 KB Output is correct
5 Correct 6 ms 256 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 256 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 256 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 6 ms 256 KB Output is correct
8 Correct 6 ms 384 KB Output is correct
9 Correct 5 ms 256 KB Output is correct
10 Correct 5 ms 256 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 3 ms 384 KB Output is correct
13 Correct 5 ms 256 KB Output is correct
14 Correct 6 ms 256 KB Output is correct
15 Correct 6 ms 256 KB Output is correct
16 Correct 6 ms 256 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 5 ms 384 KB Output is correct
19 Correct 6 ms 384 KB Output is correct
20 Correct 6 ms 256 KB Output is correct
21 Correct 102 ms 256 KB Output is correct
22 Correct 106 ms 256 KB Output is correct
23 Correct 124 ms 256 KB Output is correct
24 Correct 125 ms 256 KB Output is correct
25 Correct 131 ms 256 KB Output is correct
26 Correct 131 ms 376 KB Output is correct
27 Correct 118 ms 256 KB Output is correct
28 Correct 121 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 384 KB Output is correct
2 Correct 12 ms 256 KB Output is correct
3 Correct 597 ms 376 KB Output is correct
4 Correct 586 ms 384 KB Output is correct
5 Correct 101 ms 408 KB Output is correct
6 Correct 99 ms 384 KB Output is correct
7 Correct 581 ms 504 KB Output is correct
8 Correct 579 ms 504 KB Output is correct
9 Correct 104 ms 384 KB Output is correct
10 Correct 105 ms 376 KB Output is correct
11 Correct 342 ms 384 KB Output is correct
12 Correct 341 ms 384 KB Output is correct
13 Correct 763 ms 384 KB Output is correct
14 Correct 760 ms 504 KB Output is correct
15 Correct 114 ms 384 KB Output is correct
16 Correct 118 ms 376 KB Output is correct
17 Correct 422 ms 384 KB Output is correct
18 Correct 414 ms 384 KB Output is correct
19 Correct 755 ms 504 KB Output is correct
20 Correct 759 ms 504 KB Output is correct
21 Execution timed out 1091 ms 384 KB Time limit exceeded
22 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1090 ms 792 KB Time limit exceeded
2 Halted 0 ms 0 KB -