Skip to content

Instantly share code, notes, and snippets.

@tokoroten
Created December 2, 2013 16:17
Show Gist options
  • Save tokoroten/7752003 to your computer and use it in GitHub Desktop.
Save tokoroten/7752003 to your computer and use it in GitHub Desktop.
https://paiza.jp/poh/ec-campaign なんか採点用サーバのキューが詰まってるくさいので寝る。
def uniq_two(item_prices, max_price):
bucket = {}
for price in item_prices:
if price > max_price:
continue
if price not in bucket :
bucket[price] = 0
bucket[price] += 1
result = []
for price in bucket:
result.append(price)
if bucket[price] >= 2:
result.append(price)
return result
def max_price_stdin():
header = raw_input().split(" ")
item_num = int(header[0])
campagin_days = int(header[1])
item_prices = []
for i in xrange(item_num):
item_prices.append(int(raw_input()))
campagin_prices = []
for i in xrange(campagin_days):
campagin_prices.append(int(raw_input()))
max_campagin_price = max(campagin_prices)
item_prices = uniq_two(item_prices, max_campagin_price)
max_prices = [0] * campagin_days
for i in xrange(len(item_prices)):
p1 = item_prices[i]
for k in xrange(i + 1, len(item_prices)):
pt = p1 + item_prices[k]
if pt > max_campagin_price:
continue
for n in xrange(campagin_days):
cp = campagin_prices[n]
if pt > cp:
continue
if max_prices[n] <= pt:
max_prices[n] = pt
for price in max_prices:
print price
if __name__ == "__main__":
max_price_stdin()
@tokoroten
Copy link
Author

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