結果
問題 |
No.2623 Room Allocation
|
ユーザー |
|
提出日時 | 2024-02-11 00:53:18 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 390 ms / 2,000 ms |
コード長 | 682 bytes |
コンパイル時間 | 223 ms |
コンパイル使用メモリ | 82,092 KB |
実行使用メモリ | 106,512 KB |
最終ジャッジ日時 | 2024-09-28 17:23:03 |
合計ジャッジ時間 | 4,953 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 30 |
ソースコード
import sys, time, random from collections import deque, Counter, defaultdict input = lambda: sys.stdin.readline().rstrip() ii = lambda: int(input()) mi = lambda: map(int, input().split()) li = lambda: list(mi()) inf = 2 ** 61 - 1 mod = 998244353 n, x, y = mi() a = [0] * (x + y) b = [0] * (x + y) for i in range(n): p, c = input().split() p = int(p) if c == 'A': a[i % (x + y)] += p else: b[i % (x + y)] += p c = [a[i] - b[i] for i in range(x + y)] d = list(range(x + y)) d.sort(key = lambda x: c[x], reverse=True) ans = 0 for i in range(x + y): if i < x: ans += max(0, a[d[i]]) else: ans += max(0, b[d[i]]) print(ans)