Task: | Cent saving |
Sender: | Spitfire |
Submission time: | 2016-05-28 15:09:37 +0300 |
Language: | C++ |
Status: | READY |
Result: | WRONG ANSWER |
test | verdict | time | |
---|---|---|---|
#1 | WRONG ANSWER | 0.06 s | details |
#2 | WRONG ANSWER | 0.06 s | details |
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 ... |
correct output |
---|
475191144965 460688647850 478543444030 475238936090 456736521510 ... |
user output |
---|
475191145085 460688647960 478543444145 475238936190 456736521630 ... Truncated |
Test 2
Verdict: WRONG ANSWER
input |
---|
1 100000 666086355 190481330 514353517 ... |
correct output |
---|
47176864928795 |
user output |
---|
47176864939695 |