結果
問題 |
No.449 ゆきこーだーの雨と雪 (4)
|
ユーザー |
![]() |
提出日時 | 2025-03-31 17:48:49 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,822 bytes |
コンパイル時間 | 342 ms |
コンパイル使用メモリ | 82,296 KB |
実行使用メモリ | 106,108 KB |
最終ジャッジ日時 | 2025-03-31 17:50:13 |
合計ジャッジ時間 | 14,729 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 8 WA * 35 |
ソースコード
import bisect from collections import defaultdict n = int(input()) L = list(map(int, input().split())) T = int(input()) users = {} score_groups = defaultdict(list) output = [] for time_step in range(T): parts = input().split() name = parts[0] p = parts[1] if p != '?': # Submission query problem_idx = ord(p) - ord('A') l = L[problem_idx] old_score, old_lt = users.get(name, (0, 0)) new_score = old_score + l new_lt = time_step + 1 # Convert 0-based to 1-based time # Remove from old score group if old_score in score_groups: group = score_groups[old_score] index = bisect.bisect_left(group, (old_lt, name)) if index < len(group) and group[index] == (old_lt, name): del group[index] if not group: del score_groups[old_score] # Add to new score group new_group = score_groups[new_score] bisect.insort(new_group, (new_lt, name)) # Update user's data users[name] = (new_score, new_lt) else: # Query for rank user_score, user_lt = users[name] sorted_scores = sorted(score_groups.keys(), reverse=True) sum_bigger = 0 same_count = 0 for sc in sorted_scores: if sc > user_score: sum_bigger += len(score_groups[sc]) elif sc == user_score: group = score_groups[sc] pos = bisect.bisect_left(group, (user_lt, name)) same_count = pos break else: break # No need to check smaller scores rank = sum_bigger + same_count + 1 output.append(str(rank)) print('\n'.join(output))