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 14:54:57
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 unsigned int round(unsigned int n, unsigned int 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(unsigned int 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;
		unsigned int input;
		unsigned int 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
477687545180
464978309415
469754811210
473772861015
459378192990
484964363025
469227939745
476076446280
463968012420
480317542525
458834989560
472694971870
467845191980
475238640235
470940911790
...
view   save

user output
475191145085
460688647960
478543444145
475238936190
456736521630
477687545270
464978309530
469754811310
473772861110
459378193115
484964363120
469227939830
476076446395
463968012510
480317542635
458834989650
472694971965
467845192070
475238640335
470940911910
...
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