# How to solve the following problem?

Statement of the problem:
The ticket for one trip in metro costs 15 rubles, the ticket for 10 trips costs 125 rubles, the ticket for 60 trips costs 440 rubles. The passenger plans to make n trips. Determine how many tickets of each type he should purchase so that the total number of paid visits was not less than n, and the total cost of tickets purchased – minimum.

Input:
This single number n - the number of trips.

Output:
Print three integers equal to the desired number of tickets for 1, 10, 60 trips.

In the code below my solution to this problem. It is a greater part of the tests. In comments is the original algorithm, which is tested completely as well as out (except time). What can I do so?
``````#include <stdio.h>
int main() {
int n, n10, n60;
scanf("%d", &n);

n60 = n / 60;
n = n % 60;
n10 = n / 10;
n = n % 10;

if (n > 8) {
n = 0;
n10++;
}

if (n10 > 3) {
n10 = 0;
n60++;
}

/*long sum = n*15 + n10*125 + n60*440;
long temp = (n10 + 1)*125 + n60*440;
if (temp < sum) {
n = 0;
n10++;
sum = temp;
}

if (440*(n60 + 1) < sum) {
n10 = 0;
n60++;
}*/

printf("%d %d %d", n, n10, n60);

return 0;
}</stdio.h>``````
June 14th 19 at 19:12