結果

問題 No.2623 Room Allocation
ユーザー halshals
提出日時 2024-02-29 17:44:30
言語 Julia
(1.10.2)
結果
AC  
実行時間 880 ms / 2,000 ms
コード長 1,432 bytes
コンパイル時間 164 ms
コンパイル使用メモリ 6,940 KB
実行使用メモリ 313,132 KB
最終ジャッジ日時 2024-04-09 14:37:10
合計ジャッジ時間 27,030 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 636 ms
271,952 KB
testcase_01 AC 645 ms
273,124 KB
testcase_02 AC 639 ms
269,876 KB
testcase_03 AC 637 ms
272,460 KB
testcase_04 AC 642 ms
270,120 KB
testcase_05 AC 642 ms
271,812 KB
testcase_06 AC 843 ms
298,040 KB
testcase_07 AC 845 ms
299,472 KB
testcase_08 AC 841 ms
297,896 KB
testcase_09 AC 849 ms
299,924 KB
testcase_10 AC 641 ms
282,684 KB
testcase_11 AC 643 ms
284,500 KB
testcase_12 AC 654 ms
277,892 KB
testcase_13 AC 640 ms
277,668 KB
testcase_14 AC 865 ms
312,352 KB
testcase_15 AC 850 ms
291,180 KB
testcase_16 AC 669 ms
286,304 KB
testcase_17 AC 640 ms
272,020 KB
testcase_18 AC 851 ms
293,100 KB
testcase_19 AC 841 ms
292,748 KB
testcase_20 AC 848 ms
292,964 KB
testcase_21 AC 851 ms
292,800 KB
testcase_22 AC 831 ms
292,748 KB
testcase_23 AC 797 ms
291,336 KB
testcase_24 AC 848 ms
293,072 KB
testcase_25 AC 835 ms
294,156 KB
testcase_26 AC 642 ms
275,040 KB
testcase_27 AC 880 ms
313,132 KB
testcase_28 AC 801 ms
300,920 KB
testcase_29 AC 665 ms
291,596 KB
testcase_30 AC 877 ms
308,876 KB
testcase_31 AC 646 ms
277,280 KB
testcase_32 AC 652 ms
287,200 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()
        if c == "A"
            wantA[(i-1)%(x+y)+1] += int(p)
        else
            wantB[(i-1)%(x+y)+1] += int(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...)
if abspath(PROGRAM_FILE) == @__FILE__
    main()
else
    mystdin = joinpath(abspath(@__DIR__), "myinput.txt")
    mystdout = stdout
    redirect_stdio(stdin=mystdin, stdout=mystdout) do
        main()
    end
end
0