結果
問題 |
No.1211 円環はお断り
|
ユーザー |
![]() |
提出日時 | 2025-03-31 17:43:19 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 823 bytes |
コンパイル時間 | 221 ms |
コンパイル使用メモリ | 82,804 KB |
実行使用メモリ | 89,520 KB |
最終ジャッジ日時 | 2025-03-31 17:44:13 |
合計ジャッジ時間 | 4,565 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 36 WA * 5 |
ソースコード
import sys def main(): N, K = map(int, sys.stdin.readline().split()) A = list(map(int, sys.stdin.readline().split())) if K == 0: print(0) return if K >= N: print(min(A)) return def is_possible(mid): count = 0 current_sum = 0 for num in A: current_sum += num if current_sum >= mid: count += 1 current_sum = 0 if count >= K: return True return False low = 1 high = sum(A) ans = 0 while low <= high: mid = (low + high) // 2 if is_possible(mid): ans = mid low = mid + 1 else: high = mid - 1 print(ans) if __name__ == "__main__": main()