Skip to content

Instantly share code, notes, and snippets.

@sarthakmanna
Created February 20, 2019 10:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sarthakmanna/4077b08e27ff9e0fd7294fd5d0f3539e to your computer and use it in GitHub Desktop.
Save sarthakmanna/4077b08e27ff9e0fd7294fd5d0f3539e to your computer and use it in GitHub Desktop.
CLGAME
for tc in xrange(int(raw_input())):
N, K = map(int, raw_input().split())
ar = map(int, raw_input().split())
S = map(int, raw_input().split())
if len(set(ar)) != N or len(set(S)) != K:
1/0
win = [False for i in xrange(N + 1)]
M = max(ar)
for j in xrange(N):
if ar[j] == M: break
win[j] = True
for i in range(j, -1, -1):
for k in S:
if i + k > N: continue
elif not win[i + k]:
win[i] = True
break
print "Chef" if win[0] else "Garry"
@andyy143
Copy link

andyy143 commented Mar 2, 2019

for tc in xrange(int(raw_input())):
N, K = map(int, raw_input().split())
ar = map(int, raw_input().split())
S = map(int, raw_input().split())

if len(set(ar)) != N or len(set(S)) != K:
    1/0

win = [False for  i in xrange(N )]

M = max(ar)
for j in xrange(N):
    if ar[j] == M: break

win[j] = True
for i in range(j-1, -1, -1):
    for k in S:
        if i + k >=N: continue
        elif not win[i + k]:
            win[i] = True
            break
print "Chef" if win[0] else "Garry"

will you please explain why this is not working?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment