結果
問題 | No.2623 Room Allocation |
ユーザー |
![]() |
提出日時 | 2024-02-29 17:37:14 |
言語 | Julia (2.11.2) |
結果 |
AC
|
実行時間 | 877 ms / 2,000 ms |
コード長 | 1,189 bytes |
コンパイル時間 | 220 ms |
コンパイル使用メモリ | 6,948 KB |
実行使用メモリ | 310,060 KB |
最終ジャッジ日時 | 2024-10-01 17:48:09 |
合計ジャッジ時間 | 27,016 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 30 |
ソースコード
function main()n, x, y = int(inputs())wantA = zeros(Int, x + y)wantB = zeros(Int, x + y)for i = 1:np, c = inputs()if c == "A"wantA[(i-1)%(x+y)+1] += int(p)elsewantB[(i-1)%(x+y)+1] += int(p)endendans = 0tmp = [(abs(wantA[i] - wantB[i]), i) for i = 1:x+y]sort!(tmp, by=x -> x[1], rev=true)ischecked = falses(x + y)for (_, group) = tmpif ischecked[group]continueendischecked[group] = trueif wantA[group] > wantB[group]if x > 0ans += wantA[group]x -= 1elseans += wantB[group]y -= 1endelseif y > 0ans += wantB[group]y -= 1elseans += wantA[group]x -= 1endendendprintln(ans)end# --------input func----------input() = readline()inputs() = split(readline())int(s::AbstractChar) = parse(Int, s)int(s::AbstractString) = parse(Int, s)int(v::AbstractArray) = map(x -> parse(Int, x), v)main()