Author |
Message |
18/02/2017 17:11:43
|
Perez
Joined: 18/10/2014 18:53:59
Messages: 93
Offline
|
Alexa has two stacks of non-negative integers, stack and stack where index denotes the top of the stack. Alexa challenges Nick to play the following game:
In each move, Nick can remove one integer from the top of either stack or stack .
Nick keeps a running sum of the integers he removes from the two stacks.
Nick is disqualified from the game if, at any point, his running sum becomes greater than some integer given at the beginning of the game.
Nick's final score is the total number of integers he has removed from the two stacks.
Given , , and for games, find the maximum possible score Nick can achieve (i.e., the maximum number of integers he can remove without being disqualified) during each game and print it on a new line.
Input Format
The first line contains an integer, (the number of games). The subsequent lines describe each game in the following format:
The first line contains three space-seperated integers describing the respective values of (the number of integers in stack ), (the number of integers in stack ), and (the number that the sum of the integers removed from the two stacks cannot exceed).
The second line contains space-seperated integers describing the respective values of .
The third line contains space-seperated integers describing the respective values of .
Constraints
Subtasks
for of the maximum score.
Output Format
For each of the games, print an integer on a new line denoting the maximum possible score Nick can achieve without being disqualified.
Sample Input 0
1
5 4 10
4 2 4 6 1
2 1 8 5
Sample Output 0
4
Mojot kod
Aliiii nesto ne rabotii asalno za poveke primeri
This message was edited 2 times. Last update was at 18/02/2017 17:29:56
|
|
|
19/02/2017 14:04:10
|
BATIR
Joined: 20/06/2015 16:36:50
Messages: 155
Offline
|
Каде ја најде задачата?
|
|
|
20/02/2017 16:51:15
|
Perez
Joined: 18/10/2014 18:53:59
Messages: 93
Offline
|
HackerRank
|
|
|
20/02/2017 20:02:13
|
BATIR
Joined: 20/06/2015 16:36:50
Messages: 155
Offline
|
Ќе ја разгледам задачава, и ќе видам во најбрзо време ако можам некако да ти помогнам.
Може линк?
This message was edited 1 time. Last update was at 20/02/2017 20:03:24
|
|
|
21/02/2017 12:01:41
|
Perez
Joined: 18/10/2014 18:53:59
Messages: 93
Offline
|
https://www.hackerrank.com/contests/university-codesprint-2/challenges/game-of-two-stacks/forum poveii
|
|
|
21/02/2017 20:01:01
|
BATIR
Joined: 20/06/2015 16:36:50
Messages: 155
Offline
|
Здраво, еве пробај вака:
КОД
|
|
|
22/02/2017 21:05:58
|
Perez
Joined: 18/10/2014 18:53:59
Messages: 93
Offline
|
a kaj mene sho e problemov ? nesto ne sum ja sfatil zadacava ubavo ili ?
|
|
|
23/02/2017 17:15:24
|
despotovski01
Joined: 23/02/2014 14:36:12
Messages: 37
Offline
|
Perez wrote:a kaj mene sho e problemov ? nesto ne sum ja sfatil zadacava ubavo ili ?
Да, задачата кажува дека имаш два стека, така да мора елементите да ги вадиш од врвот на стекот (како што пишува и во задачата). Твоето решение ги сортира сите елементи, што не се усогласува со начинот на кој работи стекот, а притоа и твојот greedy пристап не би продуцирал оптимално решение и да беше задачата таква како што си ја сфатил (размисли за гранични случаи кога имаш многу мали наспроти големи броеви).
This message was edited 1 time. Last update was at 23/02/2017 17:18:16
|
|
|
|