結果
| 問題 | No.3808 Welcome to Mid Difficulty Problems |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-11-29 02:45:11 |
| 言語 | PyPy3 (8.0.1 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 903 ms / 2,000 ms |
| + 876µs | |
| コード長 | 1,378 bytes |
| 記録 | |
| コンパイル時間 | 86 ms |
| コンパイル使用メモリ | 64,468 KB |
| 実行使用メモリ | 230,888 KB |
| 最終ジャッジ日時 | 2026-11-29 02:45:23 |
| 合計ジャッジ時間 | 11,027 ms |
|
ジャッジサーバーID (参考情報) |
judge5_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 28 |
ソースコード
# https://yukicoder.me/problems/no/3808
import heapq
MAX_INT = 10 ** 18
def main():
N, T = map(int, input().split())
ab = []
for _ in range(N):
a, b = map(int, input().split())
ab.append((a, b))
base_a_map = {}
for a, b in ab:
if a not in base_a_map:
base_a_map[a] = [MAX_INT, []]
base_a_map[a][0] = min(base_a_map[a][0] ,b)
base_a_map[a][1].append(b)
base_a_array = [(key, tpl) for key, tpl in base_a_map.items()]
base_a_array.sort(key=lambda x : x[1][0])
base_time = 0
queue = []
queue_time = 0
answer = 0
for spec_index in range(len(base_a_array)):
b_array = base_a_array[spec_index][1][1]
b_array.sort()
base_time += b_array[0]
while len(queue) > 0 and queue_time + base_time > T:
b1 = heapq.heappop(queue)
queue_time += b1
for i in range(1, len(b_array)):
b0 = b_array[i]
heapq.heappush(queue, -b0)
queue_time += b0
while len(queue) > 0 and queue_time + base_time > T:
b1 = heapq.heappop(queue)
queue_time += b1
if queue_time + base_time <= T:
ans = 2 * (spec_index + 1) + len(queue)
answer = max(answer, ans)
print(answer)
if __name__ == "__main__":
main()