Code Submission Evaluation System Login

HIIT Open 2016

Start:2016-05-28 11:00:00
End:2016-05-28 16:00:00
 

Tasks | Messages | Scoreboard | Statistics


CSES - HIIT Open 2016 - Results
History
2016-05-28 15:09:37
2016-05-28 14:54:57
Task:Cent saving
Sender:Spitfire
Submission time:2016-05-28 15:09:37
Language:C++
Status:READY
Result:WRONG ANSWER

Test results

testverdicttime (s)
#1WRONG ANSWER0.06 / 1.00details
#2WRONG ANSWER0.06 / 1.00details

Code

#include <iostream>
#include <cstdint>
inline uint64_t round(uint64_t n, uint64_t d) {
	switch(d) {
		case 0:
		case 1:
		case 2:
			return (n / 10) * 10;

		case 3:
		case 4:
		case 5:
		case 6:
		case 7:
			return (n / 10) * 10 + 5;
		case 8:
		case 9:
			return (n / 10) * 10 + 10;
	}
	return 0;
}
inline bool is_cheap(uint64_t n) {
	switch(n) {
		case 0:
		case 1:
		case 2:
		case 5:
		case 6:
		case 7:
			return true;
	}
	return false;
}

int main()
{
	std::ios_base::sync_with_stdio(0);
	std::cin.tie(0);

	unsigned int t;
	std::cin >> t;

	unsigned int nb;
	for (size_t i = 0; i < t; i++) {
		std::cin >> nb;
		uint64_t input;
		uint64_t digit;
		uint64_t sum = 0;
		uint64_t temp_sum = 0;
		for (size_t j = 0; j < nb; j++) {
			std::cin >> input;
			digit = input % 10;
			if (is_cheap(digit)) {
				sum += round(input, digit);
				continue;
			}
			temp_sum += input;
			digit = temp_sum % 10;
			if (is_cheap(digit)) {
				sum += round(temp_sum, digit);
				temp_sum = 0;
			}
		}
		digit = temp_sum % 10;
		sum += round(temp_sum, digit);
		std::cout << sum << std::endl;
	}

	return 0;
}

Test details

Test 1

Verdict: WRONG ANSWER

input
100
1000
528433894 255789530 559301042 ...
view   save

correct output
475191144965
460688647850
478543444030
475238936090
456736521510
...
view   save

user output
475191145085
460688647960
478543444145
475238936190
456736521630
...
view   save

Test 2

Verdict: WRONG ANSWER

input
1
100000
666086355 190481330 514353517 ...
view   save

correct output
47176864928795

view   save

user output
47176864939695

view   save