---
# System prepended metadata

title: 13557 - Anya coin ga suki
tags: [math]

---

# 13557 - Anya coin ga suki
>author: Utin
###### tags: `math`

---

## Brief
See the code below

## Solution 0

```c=
#include<stdio.h>

int main() {
    int p, a, b, c, d;
    int sum = 0;
    scanf("%d %d %d %d %d", &p, &a, &b, &c, &d);
    if(p / 50 > 0) {
        if(p / 50 > d) {
            sum += d;
            p -= 50*d;
        }
        else {
            sum += p/50;
            p %= 50;
        }
    }
    if(p / 10 > 0) {
        if(p / 10 > c) {
            sum += c;
            p -= 10*c;
        }
        else {
            sum += p/10;
            p %= 10;
        }
    }
    if(p / 5 > 0) {
        if(p / 5 > b) {
            sum += b;
            p -= 5*b;
        }
        else {
            sum += p/5;
            p %= 5;
        }
    }
    if(p > 0) {
        if(p > a) {
            printf("%d\n", -1);
            return 0;
        }
        else {
            sum += p;
        }
    }
    printf("%d\n", sum);
    return 0;
}
// By Utin
```

## Reference