| 9 | using namespace std; |
| 10 | |
| 11 | int main() { |
| 12 | ios_base::sync_with_stdio(false); // Speeds up the execution time |
| 13 | cin.tie(NULL); |
| 14 | |
| 15 | lli t; // number of test cases |
| 16 | cin >> t; |
| 17 | |
| 18 | lli n, k; |
| 19 | |
| 20 | while (t--) { |
| 21 | cin >> n >> k; |
| 22 | |
| 23 | lli numQuery, totalDays; |
| 24 | lli queriesLeft = 0; |
| 25 | bool isQueriesRemaining = true, executeFurther = true; |
| 26 | |
| 27 | for (lli i = 1; i <= n; i++) { |
| 28 | cin >> numQuery; |
| 29 | queriesLeft += (numQuery - k); |
| 30 | |
| 31 | if(queriesLeft < 0 && executeFurther) { // execute this when the chef gets his first free day. |
| 32 | totalDays = i; |
| 33 | isQueriesRemaining = false; |
| 34 | executeFurther = false; |
| 35 | } |
| 36 | } |
| 37 | |
| 38 | if(isQueriesRemaining) { // when queries are remaining to be solved |
| 39 | cout << n + (queriesLeft / k) + 1 << endl; |
| 40 | } else { |
| 41 | cout << totalDays << endl; |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | return 0; |
| 46 | } |
nothing calls this directly
no outgoing calls
no test coverage detected