CodeforcesJun 25, 2025

Birthday

Hazrat Ali

Codeforces

Ivan is collecting coins. There are only N different collectible coins, Ivan has K of them. He will be celebrating his birthday soon, so all his M freinds decided to gift him coins. They all agreed to three terms:

  • Everyone must gift as many coins as others.
  • All coins given to Ivan must be different.
  • Not less than L coins from gifts altogether, must be new in Ivan's collection.

But his friends don't know which coins have Ivan already got in his collection. They don't want to spend money so they want to buy minimum quantity of coins, that satisfy all terms, irrespective of the Ivan's collection. Help them to find this minimum number of coins or define it's not possible to meet all the terms.

Input

The only line of input contains 4 integers NMKL (1KNM,L≤10) — quantity of different coins, number of Ivan's friends, size of Ivan's collection and quantity of coins, that must be new in Ivan's collection.

Output

Print one number  minimal number of coins one friend can gift to satisfy all the conditions. If it is impossible to satisfy all three conditions print "-1" (without quotes).

Examples
Input
20 15 2 3
Output
1
Input
10 11 2 4
Output
-1


Solution

#include <bits/stdc++.h>
using namespace std;

int main()
{
    long long a, b, x, y;
    cin >> a >> b >> x >> y;
    long long ans = -1;
    if (b <= n)
    {
        long long temp = (y + k) / b;
        while (temp * b <= a)
        {
            if (temp * b - k >= y)
            {
                ans = temp;
                break;
            }
            temp++;
        }
    }
    cout << ans << endl;
    return 0;
}






Comments