結果
問題 | No.2623 Room Allocation |
ユーザー |
|
提出日時 | 2024-08-18 10:30:18 |
言語 | Rust (1.83.0 + proconio) |
結果 |
AC
|
実行時間 | 44 ms / 2,000 ms |
コード長 | 552 bytes |
コンパイル時間 | 16,251 ms |
コンパイル使用メモリ | 402,220 KB |
実行使用メモリ | 17,024 KB |
最終ジャッジ日時 | 2024-08-18 10:30:44 |
合計ジャッジ時間 | 19,381 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 30 |
ソースコード
use proconio::input; fn main() { input! { n:usize, x:usize, y:usize, pc:[(i64,char);n], } let mut abs = vec![(0, 0); x + y]; for i in 0..n { if pc[i].1 == 'A' { abs[i % (x + y)].0 += pc[i].0; } else { abs[i % (x + y)].1 += pc[i].0; } } abs.sort_by(|&x, &y| (y.0 - y.1).cmp(&(x.0 - x.1))); let mut ans = 0; for i in 0..x { ans += abs[i].0; } for i in 0..y { ans += abs[x + i].1; } println!("{}", ans); }