codeforces-scrape

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

203A.md (2784B)


      1 Source: https://codeforces.com/problemset/problem/203/A
      2 
      3 A. Two Problems
      4 
      5 time limit per test
      6 
      7 2 seconds
      8 
      9 memory limit per test
     10 
     11 256 megabytes
     12 
     13 input
     14 
     15 stdin
     16 
     17 output
     18 
     19 stdout
     20 
     21 A boy Valera registered on site Codeforces as Valera, and wrote his first Codeforces Round #300. He boasted to a friend Arkady about winning as much as *x* points for his first contest. But Arkady did not believe his friend's words and decided to check whether Valera could have shown such a result.
     22 
     23 He knows that the contest number 300 was unusual because there were only two problems. The contest lasted for *t* minutes, the minutes are numbered starting from zero. The first problem had the initial cost of *a* points, and every minute its cost reduced by *d**a* points. The second problem had the initial cost of *b* points, and every minute this cost reduced by *d**b* points. Thus, as soon as the zero minute of the contest is over, the first problem will cost *a* - *d**a* points, and the second problem will cost *b* - *d**b* points. It is guaranteed that at any moment of the contest each problem has a non-negative cost.
     24 
     25 Arkady asks you to find out whether Valera could have got exactly *x* points for this contest. You should assume that Valera could have solved any number of the offered problems. You should also assume that for each problem Valera made no more than one attempt, besides, he could have submitted both problems at the same minute of the contest, starting with minute 0 and ending with minute number *t* - 1. Please note that Valera can't submit a solution exactly *t* minutes after the start of the contest or later.
     26 
     27 Input
     28 
     29 The single line of the input contains six integers *x*, *t*, *a*, *b*, *d**a*, *d**b* (0 ≤ *x* ≤ 600; 1 ≤ *t*, *a*, *b*, *d**a*, *d**b* ≤ 300) — Valera's result, the contest's duration, the initial cost of the first problem, the initial cost of the second problem, the number of points that the first and the second problem lose per minute, correspondingly.
     30 
     31 It is guaranteed that at each minute of the contest each problem has a non-negative cost, that is, *a* - *i*·*d**a* ≥ 0 and *b* - *i*·*d**b* ≥ 0 for all 0 ≤ *i* ≤ *t* - 1.
     32 
     33 Output
     34 
     35 If Valera could have earned exactly *x* points at a contest, print "YES", otherwise print "NO" (without the quotes).
     36 
     37 Examples
     38 
     39 Input
     40 
     41 ```
     42 30 5 20 20 3 5
     43 ```
     44 
     45 Output
     46 
     47 ```
     48 YES
     49 ```
     50 
     51 Input
     52 
     53 ```
     54 10 4 100 5 5 1
     55 ```
     56 
     57 Output
     58 
     59 ```
     60 NO
     61 ```
     62 
     63 Note
     64 
     65 In the first sample Valera could have acted like this: he could have submitted the first problem at minute 0 and the second problem — at minute 2. Then the first problem brings him 20 points and the second problem brings him 10 points, that in total gives the required 30 points.