icpc 2018 problem E

This commit is contained in:
Xevion
2019-08-24 19:31:42 -05:00
parent f6370de2ef
commit ca2b4f1848
4 changed files with 26 additions and 1 deletions

View File

@@ -46,6 +46,8 @@ def processWord(word):
# print(index, select, word[index:index + select[1]])
word = word[:index] + (select[0].title() if select[2].istitle() else select[0]) + word[index + select[1]:]
# word[index:index + select[1]] = select[0]
index += len(select[0])
else:
index += 1
return word

View File

@@ -0,0 +1 @@
725.85 1.71 2.38

View File

@@ -0,0 +1 @@
100.00 20.00 10.00

View File

@@ -0,0 +1,21 @@
import os, sys
# Process a single input
def process(profit, pita, pizza):
maxPita, maxPizza = int(profit / pita), int(profit / pizza)
combos = [(x, y) for x in range(0, maxPita + 1) for y in range(0, maxPizza + 1)]
combos = filter(lambda item : profit == (pita * item[0]) + (pizza * item[1]), combos)
return '\n'.join(' '.join(map(str, combo)) for combo in combos)
# Driver code for all inputs in folder
def main():
# Read inputs
inputs = [os.path.join(sys.path[0], 'inputs', x) for x in
os.listdir(os.path.join(sys.path[0], 'inputs'))]
# Parse inputs
inputs = [list(map(float, open(path).read().split())) for path in inputs]
# Process inputs and print outputs
print('\n'.join(map(lambda item : process(*item), inputs)))
if __name__ == "__main__":
main()