Submission #1216725

#TimeUsernameProblemLanguageResultExecution timeMemory
1216725giorgi123glmRice Hub (IOI11_ricehub)C++20
42 / 100
1096 ms584 KiB
#include "ricehub.h"
#include <cstdlib>
#include <set>
#include <vector>
using namespace std;

int besthub(int R, int L, int X[], long long B) {
	int ans = 0;
	for (int i = 0; i < R; i++) {
		// chooce rice hub
		int tempB = B;

		multiset <int> s;
		for (int j = 0; j < R; j++)
			s.emplace (abs (X[i] - X[j]));

		int curans = 0;
		while (s.size() && *s.begin() <= tempB) {
			tempB -= *s.begin();
			s.erase (s.begin());
			curans++;
		}

		ans = max (curans, ans);
	}

	return ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...