Submission #614807

# Submission time Handle Problem Language Result Execution time Memory
614807 2022-07-31T04:59:40 Z Shithila Rice Hub (IOI11_ricehub) C++14
0 / 100
1000 ms 504 KB
#include "ricehub.h"
#include <bits/stdc++.h>
using namespace std;
int besthub(int R, int L, int X[], long long B)
{
	int dis[R];
	int pos=0;
	int max=0;
  	for(int i=0;i<L;i++)
  	{
  		for(int j=0;j<R;j++)
  		{
  			dis[j]=abs(i-X[j]);
		}
		sort(dis,dis+R);
		int sum=0;
		int j=0;
		while(sum<=B && i<R)
		{
			sum=sum+dis[j];
			j++;
		}
		sum=sum-dis[j];
		if(max<sum)
		{
			max=sum;
			pos=i;
		}
  	}	
  	return max;
}

Compilation message

ricehub.cpp: In function 'int besthub(int, int, int*, long long int)':
ricehub.cpp:7:6: warning: variable 'pos' set but not used [-Wunused-but-set-variable]
    7 |  int pos=0;
      |      ^~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 312 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 19 ms 308 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1066 ms 504 KB Time limit exceeded
2 Halted 0 ms 0 KB -