Created
June 29, 2015 15:17
-
-
Save nishidy/7e1392fa3333607b2577 to your computer and use it in GitHub Desktop.
Round 1C 2015: Problem C. Less Money, More Problems
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
T=int(raw_input()) | |
t=0 | |
while t<T: | |
C,D,V=map(lambda x:int(x),raw_input().split()) | |
d=sorted(map(lambda x:int(x),raw_input().split())) | |
a=0;n=1;s=0;pn=0 | |
while n<=V: | |
if n in d: | |
n,s,pn=(n*C)+s+1,(n*C)+s,n | |
else: | |
for j in range(D): | |
if n>d[j] and d[j]>pn: | |
k=0 | |
while j+k<D and n>d[j+k] and d[j+k]>pn: | |
s+=d[j+k]*C | |
k+=1 | |
n,pn=s+1,n | |
break | |
if d[j]>n: | |
a+=1 | |
n,s,pn=(n*C)+s+1,(n*C)+s,n | |
break | |
else: | |
a+=1 | |
n,s,pn=(n*C)+s+1,(n*C)+s,n | |
t+=1 | |
print "Case #%d: %d"%(t,a) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment