結果
問題 |
No.449 ゆきこーだーの雨と雪 (4)
|
ユーザー |
![]() |
提出日時 | 2025-06-12 21:05:27 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,731 bytes |
コンパイル時間 | 218 ms |
コンパイル使用メモリ | 82,172 KB |
実行使用メモリ | 101,280 KB |
最終ジャッジ日時 | 2025-06-12 21:06:45 |
合計ジャッジ時間 | 16,341 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 8 WA * 35 |
ソースコード
import bisect from collections import defaultdict n = int(input()) L = list(map(int, input().split())) sum_L = sum(L) T = int(input()) freq = [0] * (sum_L + 2) # freq[total] is the number of users with this total. times_dict = defaultdict(list) user_info = dict() # name: (total, last_time) for time_step in range(1, T + 1): parts = input().split() name = parts[0] p = parts[1] if p == '?': # Query case total, last_time = user_info[name] sum_high = 0 for t in range(total + 1, sum_L + 1): sum_high += freq[t] same_list = times_dict.get(total, []) same_count = bisect.bisect_left(same_list, last_time) print(sum_high + same_count + 1) else: # Solve case problem_index = ord(p) - ord('A') problem_level = L[problem_index] # Get old_total and old_time if name in user_info: old_total, old_time = user_info[name] else: old_total = 0 old_time = 0 new_total = old_total + problem_level new_time = time_step # Remove from old_total if old_total > 0 if old_total > 0: lst = times_dict[old_total] idx = bisect.bisect_left(lst, old_time) if idx < len(lst) and lst[idx] == old_time: del lst[idx] # Decrement the frequency of old_total freq[old_total] -= 1 # Add to new_total lst = times_dict[new_total] bisect.insort(lst, new_time) # Increment the frequency of new_total freq[new_total] += 1 # Update user_info user_info[name] = (new_total, new_time)