結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 585 ms
269,824 KB
testcase_01 AC 583 ms
270,464 KB
testcase_02 AC 586 ms
271,120 KB
testcase_03 AC 588 ms
270,232 KB
testcase_04 AC 584 ms
271,780 KB
testcase_05 AC 587 ms
272,676 KB
testcase_06 AC 781 ms
298,288 KB
testcase_07 AC 776 ms
297,724 KB
testcase_08 AC 775 ms
296,192 KB
testcase_09 AC 785 ms
299,636 KB
testcase_10 AC 597 ms
282,564 KB
testcase_11 AC 597 ms
282,352 KB
testcase_12 AC 591 ms
277,996 KB
testcase_13 AC 592 ms
276,056 KB
testcase_14 AC 810 ms
311,804 KB
testcase_15 AC 791 ms
295,236 KB
testcase_16 AC 611 ms
284,256 KB
testcase_17 AC 589 ms
270,500 KB
testcase_18 AC 797 ms
293,416 KB
testcase_19 AC 831 ms
292,420 KB
testcase_20 AC 819 ms
293,824 KB
testcase_21 AC 820 ms
292,844 KB
testcase_22 AC 797 ms
293,004 KB
testcase_23 AC 771 ms
292,588 KB
testcase_24 AC 820 ms
292,688 KB
testcase_25 AC 801 ms
292,372 KB
testcase_26 AC 611 ms
275,880 KB
testcase_27 AC 847 ms
310,664 KB
testcase_28 AC 780 ms
300,668 KB
testcase_29 AC 644 ms
290,376 KB
testcase_30 AC 850 ms
310,576 KB
testcase_31 AC 633 ms
274,904 KB
testcase_32 AC 634 ms
287,752 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)
main()
0