結果
問題 |
No.1007 コイン集め
|
ユーザー |
|
提出日時 | 2020-04-24 13:50:11 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,056 bytes |
コンパイル時間 | 89 ms |
コンパイル使用メモリ | 12,800 KB |
実行使用メモリ | 21,744 KB |
最終ジャッジ日時 | 2024-10-15 01:50:05 |
合計ジャッジ時間 | 1,971 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 15 WA * 4 |
ソースコード
def main(): length, start = map(int, input().split()) start -= 1 coins = [int(x) for x in input().split()] small_coin_index = [] for i in range(length): if i == start: continue if coins[i] < 2: small_coin_index.append(i) answer = coins[start] if not small_coin_index: answer = sum(coins) elif coins[start] > 0: move_range = [0, 0] small_coin_index.sort() if small_coin_index[-1] < start: answer = sum(coins[small_coin_index[-1]:]) elif start < small_coin_index[0]: answer = sum(coins[:small_coin_index[0] + 1]) else: for i in range(len(small_coin_index) - 1): if small_coin_index[i] < start < small_coin_index[i + 1]: move_range[0] = small_coin_index[i] move_range[1] = small_coin_index[i + 1] break answer = sum(coins[move_range[0]:move_range[1] + 1]) print(answer) if __name__ == '__main__': main()