結果

問題 No.2623 Room Allocation
ユーザー halshals
提出日時 2024-02-29 17:33:06
言語 Julia
(1.10.2)
結果
AC  
実行時間 823 ms / 2,000 ms
コード長 1,359 bytes
コンパイル時間 216 ms
コンパイル使用メモリ 7,068 KB
実行使用メモリ 311,452 KB
最終ジャッジ日時 2024-04-09 14:36:37
合計ジャッジ時間 25,449 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 583 ms
269,920 KB
testcase_01 AC 591 ms
271,684 KB
testcase_02 AC 582 ms
272,124 KB
testcase_03 AC 586 ms
272,224 KB
testcase_04 AC 590 ms
270,200 KB
testcase_05 AC 587 ms
272,124 KB
testcase_06 AC 780 ms
299,500 KB
testcase_07 AC 778 ms
299,588 KB
testcase_08 AC 778 ms
296,548 KB
testcase_09 AC 778 ms
299,508 KB
testcase_10 AC 594 ms
282,428 KB
testcase_11 AC 592 ms
283,180 KB
testcase_12 AC 593 ms
276,352 KB
testcase_13 AC 594 ms
278,328 KB
testcase_14 AC 813 ms
311,452 KB
testcase_15 AC 801 ms
293,568 KB
testcase_16 AC 624 ms
286,400 KB
testcase_17 AC 585 ms
272,400 KB
testcase_18 AC 798 ms
292,880 KB
testcase_19 AC 792 ms
292,952 KB
testcase_20 AC 795 ms
292,864 KB
testcase_21 AC 789 ms
290,952 KB
testcase_22 AC 771 ms
293,144 KB
testcase_23 AC 743 ms
292,816 KB
testcase_24 AC 794 ms
293,372 KB
testcase_25 AC 774 ms
292,796 KB
testcase_26 AC 594 ms
276,372 KB
testcase_27 AC 823 ms
310,920 KB
testcase_28 AC 745 ms
299,392 KB
testcase_29 AC 625 ms
290,496 KB
testcase_30 AC 820 ms
308,800 KB
testcase_31 AC 597 ms
277,404 KB
testcase_32 AC 619 ms
287,132 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

function main()
    n, x, y = int(inputs())
    wantA = zeros(Int, x + y)
    wantB = zeros(Int, x + y)
    for i = 1:n
        p, c = inputs()
        p = int(p)
        if c == "A"
            wantA[(i-1)%(x+y)+1] += p
        else
            wantB[(i-1)%(x+y)+1] += p
        end
    end
    ans = 0
    tmp = [(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) = tmp
        if ischecked[group]
            continue
        end
        ischecked[group] = true
        if wantA[group] > wantB[group]
            if x > 0
                ans += wantA[group]
                x -= 1
            else
                ans += wantB[group]
                y -= 1
            end
        else
            if y > 0
                ans += wantB[group]
                y -= 1
            else
                ans += wantA[group]
                x -= 1
            end
        end
    end
    println(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)
debug(x...) = println(stderr, x...)
isfile("myinput.txt") && (mystdin = open("myinput.txt", "r"); redirect_stdin(mystdin))
main()
@isdefined(mystdin) && close(mystdin)
0