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

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:33:21: error: 'floor' was not declared in this scope
   33 |                 if (floor(mean) == numbers[k]) {
      |                     ^~~~~
input/code.cpp:40:38: error: 'ceil' was not declared in this scope
   40 |                         std::cout << ceil(mean) - numbers[0] << endl;
      |                                      ^~~~

Code

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

using namespace std;

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;
}