GOOGLE HASHCODE 2020

Because Input is from a file. Its not regular input.

Can anyone please explain me the process of problem execution in google hashcode . I am new to it .

1 Like

I solve this practice problem with python.

2 Likes

195+194+189+185+184+179+172+169+160+157+156+149+145+135+120+114+113+103+97+94+93+92+77+76+68+65+63+62+61+56+46+45+41+34+32+30+29+28+14+13+12+7

in case medium removing the duplicate gives maximum value of 4054 then how its possible to score 4495

@sivapriyan mine is 4500. It’s because, I give the actual input and get the output for the maximum number of slice.

7 12 12 13 14 28 29 29 30 32 32 34 41 45 46 56 61 61 62 63 65 68 76 77 77 92 93 94 97 103 113 114 114 120 135 145 145 149 156 157 160 169 172 179 184 185 189 194 195 195

these are my actual inputs

they said at most one pizza of each type which means you cannot order pizza with same slice numbers is in it ?

Your ordered pizza of different type is only 42. But it should be 47.
You can order slices of pizza equal to your maximum number of participant without using same slice numbered pizza. Just try to think what different type pizza(without using same slice numbers) should I add for reach the maximum. Is 4054 is maximum? No. It is 4500, I mean K=4500. For the first Datacase it was 16, 1 less then the participant number. Because, you can’t make it 17 using one type of pizza for once. But in Dataset C, You can.

Download the input files mentioned in the problem statement and keep them organised in a folder then code and submit the output file which Ur codes generates.

1 Like

Hey guys! I used python and got a total score of 1505004318! basically 299 of from perfect score.
Unfortunately I made a really stupid mistake which I was able to fix after the submission period has ended…
For anyone curious, here is my solution (only 30 lines) and executes in less than 1 second

def main(inputfile, outputfile):
with open(inputfile) as f:
first_line = f.readline()
second_line = f.readline()

maxslices = int(first_line.split()[0])
types = second_line.split()

#convert string to integer list
for i in range(0, len(types)):
	types[i] = int(types[i])

ordering_list = []
output_list = []
total = 0

for i in range(0, len(types)):
	cur_type = 0-(i+1)
	total = sum(ordering_list)
	if(total + types[cur_type] < maxslices):
		ordering_list.append(types[cur_type])
		output_list.append(len(types)-i)

output_str = ' '.join(map(str, output_list[::-1]))
output_length = len(output_list)

with open(outputfile, 'w') as out:
	out.write('{}\n{}'.format(str(output_length), output_str))

#main(“e_also_big.in”, “e_also_big.out”)

sorry for not writing comments, i did it quick and dirty