CSES - Datatähti 2025 alku - Results
Submission details
Task:Tikut
Sender:OorigamiK
Submission time:2024-10-28 02:26:52 +0200
Language:C++ (C++20)
Status:COMPILE ERROR

Compiler report

input/code.cpp: In function 'int split(std::vector<int>&, int, int)':
input/code.cpp:10:1: warning: no return statement in function returning non-void [-Wreturn-type]
   10 | }
      | ^
input/code.cpp: In function 'int main()':
input/code.cpp:38:21: error: 'floor' was not declared in this scope
   38 |                 if (floor(mean) == numbers[k]) {
      |                     ^~~~~
input/code.cpp:43:38: error: 'ceil' was not declared in this scope
   43 |                         std::cout << ceil(mean) - numbers[0] << endl;
      |                                      ^~~~

Code

#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int split(std::vector<int>& numbers, int k, int sum) {
	

}

int main() {
	std::vector<int> numbers;
	int n, m;
	int number;
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		cin >> number;
		numbers.push_back(number);

	}
	sort(numbers.begin(), numbers.end());

	for (int i = 0; i < m; i++) {
		int sum = numbers[n-1];
		int k = n - 2;
		if (!(float(sum) / (i + 2) <= numbers[k] && k >= 0)) {
			cout << sum << " " << k+1 << " " << i << endl;
		}
		while (float(sum) / (i+2) <= numbers[k] && k>=0) {
			cout << sum << " " << k<<" "<<i << endl;
			sum += numbers[k];
			k--;
		}
		k++;
		float mean = float(sum) / (i + 2);
		std::cout << "k " << numbers[k] << endl;
		if (floor(mean) == numbers[k]) {
			std::cout <<"f "<<mean<<" "<<numbers[k]<<" " << floor(mean) - numbers[0] << endl;
		}
		else {
			if (mean>numbers[0])
			std::cout << ceil(mean) - numbers[0] << endl;

		}
		//std::cout << float(sum) / (i + 2) << endl;
	}
	return 1;
}