Skip to content

Instantly share code, notes, and snippets.

@Getmrahul
Last active January 15, 2017 19:13
Show Gist options
  • Save Getmrahul/d6f0f26cbd756e77dee3d1102a062f9a to your computer and use it in GitHub Desktop.
Save Getmrahul/d6f0f26cbd756e77dee3d1102a062f9a to your computer and use it in GitHub Desktop.
HackerCup 2017 Round 1 - Pie Progress Python Solution
# ! usr/bin/python
#
# Download Input & Output files : https://www.dropbox.com/sh/bvnrwslazmr5ztc/AACZYKtzHq1mY4YrRQN-GFbDa?dl=0
#
f = open("pieprogress.txt")
wf = open("out_pie.txt","w")
cases = int(f.readline())
for case in xrange(1, cases+1):
n, m = map(int, (f.readline()).split(" "))
minCost = 0
pie_q = []
for date in xrange(0, n):
day = sorted(map(int, (f.readline()).split(" ")))
i = 0
tax = 1
while i < m:
day[i] += tax
i += 1
tax += 2
pie_q = sorted(day+pie_q)
minCost += pie_q[0]
pie_q.pop(0)
ttt = "Case #%d: %d\n" % (case, minCost)
wf.write(ttt)
f.close()
wf.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment