Submission #224669

# Submission time Handle Problem Language Result Execution time Memory
224669 2020-04-18T14:44:05 Z Amy313 Rice Hub (IOI11_ricehub) C++14
Compilation error
0 ms 0 KB
#include "ricehub.h"
#include<bits/stdc++.h>
using namespace std;
int besthub(int R, int L, int X[], long long B)
{vector<int>V;
	int maxi= 0, c, a;
	long long cp = B;
	for(int i=1; i<=L; i++)
	{
		c = 0;
		cp = B;	

		for(int j=0; j<R; j++)
		{
			a = abs(i-X[j]);
			V.push_back(a);
		}
		sort(V.begin(), V.end());
		for(int i=0; i<V.size(); i++)
		{
			if(V[j]<=cp)
			{
				cp-=V[j];
				c++;
			}
			else
			{
				break;
			}
		}
		if(c>maxi)
		{
			maxi = c;
		}
	}
  return maxi;
}

Compilation message

ricehub.cpp: In function 'int besthub(int, int, int*, long long int)':
ricehub.cpp:19:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i=0; i<V.size(); i++)
                ~^~~~~~~~~
ricehub.cpp:21:9: error: 'j' was not declared in this scope
    if(V[j]<=cp)
         ^