Created
December 2, 2013 16:17
-
-
Save tokoroten/7752003 to your computer and use it in GitHub Desktop.
https://paiza.jp/poh/ec-campaign
なんか採点用サーバのキューが詰まってるくさいので寝る。
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
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() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
http://gyazo.com/ca09cfae8843388cec80c546e3d8538d
鯖重すぎ