codeforces-scrape

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

1760F.md (2610B)


      1 Source: https://codeforces.com/problemset/problem/1760/F
      2 
      3 F. Quests
      4 
      5 time limit per test
      6 
      7 3 seconds
      8 
      9 memory limit per test
     10 
     11 256 megabytes
     12 
     13 input
     14 
     15 standard input
     16 
     17 output
     18 
     19 standard output
     20 
     21 There are $n$ quests. If you complete the $i$-th quest, you will gain $a_i$ coins. You can only complete at most one quest per day. However, once you complete a quest, you cannot do the same quest again for $k$ days. (For example, if $k=2$ and you do quest $1$ on day $1$, then you cannot do it on day $2$ or $3$, but you can do it again on day $4$.)
     22 
     23 You are given two integers $c$ and $d$. Find the maximum value of $k$ such that you can gain at least $c$ coins over $d$ days. If no such $k$ exists, output Impossible. If $k$ can be arbitrarily large, output Infinity.
     24 
     25 Input
     26 
     27 The input consists of multiple test cases. The first line contains an integer $t$ ($1 \leq t \leq 10^4$) — the number of test cases. The description of the test cases follows.
     28 
     29 The first line of each test case contains three integers $n,c,d$ ($2 \leq n \leq 2\cdot10^5$; $1 \leq c \leq 10^{16}$; $1 \leq d \leq 2\cdot10^5$) — the number of quests, the number of coins you need, and the number of days.
     30 
     31 The second line of each test case contains $n$ integers $a_1, a_2, \dots, a_n$ ($1 \leq a_i \leq 10^9$) — the rewards for the quests.
     32 
     33 The sum of $n$ over all test cases does not exceed $2\cdot10^5$, and the sum of $d$ over all test cases does not exceed $2\cdot10^5$.
     34 
     35 Output
     36 
     37 For each test case, output one of the following.
     38 
     39 * If no such $k$ exists, output Impossible.
     40 * If $k$ can be arbitrarily large, output Infinity.
     41 * Otherwise, output a single integer — the maximum value of $k$ such that you can gain at least $c$ coins over $d$ days.
     42 
     43 Please note, the checker is case-sensitive, and you should output strings exactly as they are given.
     44 
     45 Example
     46 
     47 Input
     48 
     49 ```
     50 6
     51 
     52 2 5 4
     53 
     54 1 2
     55 
     56 2 20 10
     57 
     58 100 10
     59 
     60 3 100 3
     61 
     62 7 2 6
     63 
     64 4 20 3
     65 
     66 4 5 6 7
     67 
     68 4 100000000000 2022
     69 
     70 8217734 927368 26389746 627896974
     71 
     72 2 20 4
     73 
     74 5 1
     75 ```
     76 
     77 Output
     78 
     79 ```
     80 2
     81 Infinity
     82 Impossible
     83 1
     84 12
     85 0
     86 ```
     87 
     88 Note
     89 
     90 In the first test case, one way to earn $5$ coins over $4$ days with $k=2$ is as follows:
     91 
     92 * Day 1: do quest 2, and earn $2$ coins.
     93 * Day 2: do quest 1, and earn $1$ coin.
     94 * Day 3: do nothing.
     95 * Day 4: do quest 2, and earn $2$ coins.
     96 
     97 In total, we earned $2+1+2=5$ coins.
     98 
     99 In the second test case, we can make over $20$ coins on the first day itself by doing the first quest to earn $100$ coins, so the value of $k$ can be arbitrarily large, since we never need to do another quest.
    100 
    101 In the third test case, no matter what we do, we can't earn $100$ coins over $3$ days.