codeforces-scrape

Codeforces scraped problems and editorials
git clone git://git.laack.co/codeforces-scrape.git
Log | Files | Refs | README

765C.md (1364B)


      1 Source: https://codeforces.com/problemset/problem/765/C
      2 
      3 C. Table Tennis Game 2
      4 
      5 time limit per test
      6 
      7 2 seconds
      8 
      9 memory limit per test
     10 
     11 512 megabytes
     12 
     13 input
     14 
     15 standard input
     16 
     17 output
     18 
     19 standard output
     20 
     21 Misha and Vanya have played several table tennis sets. Each set consists of several serves, each serve is won by one of the players, he receives one point and the loser receives nothing. Once one of the players scores exactly *k* points, the score is reset and a new set begins.
     22 
     23 Across all the sets Misha scored *a* points in total, and Vanya scored *b* points. Given this information, determine the maximum number of sets they could have played, or that the situation is impossible.
     24 
     25 Note that the game consisted of several complete sets.
     26 
     27 Input
     28 
     29 The first line contains three space-separated integers *k*, *a* and *b* (1 ≤ *k* ≤ 109, 0 ≤ *a*, *b* ≤ 109, *a* + *b* > 0).
     30 
     31 Output
     32 
     33 If the situation is impossible, print a single number -1. Otherwise, print the maximum possible number of sets.
     34 
     35 Examples
     36 
     37 Input
     38 
     39 ```
     40 11 11 5
     41 ```
     42 
     43 Output
     44 
     45 ```
     46 1
     47 ```
     48 
     49 Input
     50 
     51 ```
     52 11 2 3
     53 ```
     54 
     55 Output
     56 
     57 ```
     58 -1
     59 ```
     60 
     61 Note
     62 
     63 Note that the rules of the game in this problem differ from the real table tennis game, for example, the rule of "balance" (the winning player has to be at least two points ahead to win a set) has no power within the present problem.