結果
問題 |
No.449 ゆきこーだーの雨と雪 (4)
|
ユーザー |
![]() |
提出日時 | 2025-06-12 16:30:04 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 3,267 bytes |
コンパイル時間 | 280 ms |
コンパイル使用メモリ | 82,432 KB |
実行使用メモリ | 130,268 KB |
最終ジャッジ日時 | 2025-06-12 16:30:49 |
合計ジャッジ時間 | 20,516 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 8 WA * 35 |
ソースコード
import bisect from collections import defaultdict # Read input N = int(input()) L = list(map(int, input().split())) T = int(input()) submissions = [] for _ in range(T): name, p = input().split() submissions.append((name, p)) # Initialize data structures user_states = dict() # name: (score, max_level, time) freq = [0] * (157) # 0 to 156 inclusive max_freq = defaultdict(lambda: [0] * 7) # key: score, value: list of counts for levels 0-6 time_dict = defaultdict(list) # key: (score, max_level), value: list of times (sorted) name_dict = dict() # key: (score, max_level, time), value: name current_step = 1 # starts at 1 for the first submission for submission in submissions: name, p = submission if p == '?': # Process query if name not in user_states: s, l, t = 0, 0, 10**18 else: s, l, t = user_states[name] # Compute counts count1 = 0 for s_new in range(s + 1, 157): count1 += freq[s_new] count2 = 0 if s in max_freq: for l_new in range(l + 1, 7): count2 += max_freq[s][l_new] count3 = 0 if (s, l) in time_dict: times = time_dict[(s, l)] count3 = bisect.bisect_left(times, t) count4 = 0 key = (s, l, t) if key in name_dict: other_name = name_dict[key] if other_name < name: count4 = 1 rank = count1 + count2 + count3 + count4 + 1 print(rank) else: # Process submission idx = ord(p) - ord('A') L_p = L[idx] if name not in user_states: s_old, l_old, t_old = 0, 0, 10**18 else: s_old, l_old, t_old = user_states[name] s_new = s_old + L_p if L_p > l_old: l_new = L_p t_new = current_step elif L_p == l_old: if current_step < t_old: t_new = current_step else: t_new = t_old l_new = l_old else: l_new = l_old t_new = t_old # Update data structures # Decrement old state freq[s_old] -= 1 if max_freq[s_old][l_old] > 0: max_freq[s_old][l_old] -= 1 # Remove from time_dict if (s_old, l_old) in time_dict: times = time_dict[(s_old, l_old)] idx = bisect.bisect_left(times, t_old) if idx < len(times) and times[idx] == t_old: del times[idx] if not times: del time_dict[(s_old, l_old)] # Remove from name_dict key_old = (s_old, l_old, t_old) if key_old in name_dict: del name_dict[key_old] # Increment new state freq[s_new] += 1 max_freq[s_new][l_new] += 1 # Add to time_dict if (s_new, l_new) not in time_dict: time_dict[(s_new, l_new)] = [] time_dict[(s_new, l_new)].append(t_new) # Add to name_dict key_new = (s_new, l_new, t_new) name_dict[key_new] = name # Update user_states user_states[name] = (s_new, l_new, t_new) # Increment current_step current_step += 1