結果

問題 No.1650 Moving Coins
ユーザー tamatotamato
提出日時 2021-08-20 21:48:52
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 238 ms / 2,000 ms
コード長 693 bytes
コンパイル時間 271 ms
コンパイル使用メモリ 82,580 KB
実行使用メモリ 134,888 KB
最終ジャッジ日時 2024-04-22 04:15:23
合計ジャッジ時間 8,308 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
52,352 KB
testcase_01 AC 36 ms
52,352 KB
testcase_02 AC 35 ms
52,480 KB
testcase_03 AC 105 ms
76,844 KB
testcase_04 AC 93 ms
76,928 KB
testcase_05 AC 102 ms
76,804 KB
testcase_06 AC 105 ms
76,668 KB
testcase_07 AC 108 ms
76,928 KB
testcase_08 AC 191 ms
106,184 KB
testcase_09 AC 191 ms
102,280 KB
testcase_10 AC 194 ms
106,824 KB
testcase_11 AC 203 ms
105,848 KB
testcase_12 AC 160 ms
91,600 KB
testcase_13 AC 171 ms
91,392 KB
testcase_14 AC 186 ms
102,520 KB
testcase_15 AC 148 ms
89,728 KB
testcase_16 AC 203 ms
112,596 KB
testcase_17 AC 219 ms
111,968 KB
testcase_18 AC 224 ms
121,864 KB
testcase_19 AC 235 ms
134,888 KB
testcase_20 AC 223 ms
128,892 KB
testcase_21 AC 238 ms
129,660 KB
testcase_22 AC 226 ms
125,524 KB
testcase_23 AC 223 ms
125,448 KB
testcase_24 AC 105 ms
77,184 KB
testcase_25 AC 108 ms
76,980 KB
testcase_26 AC 147 ms
129,208 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    A.append(10**7)
    B.append(10**7)
    N += 1

    st = []
    ans = []
    S = 0
    for i in range(N):
        a = A[i]
        b = B[i]
        S += abs(a - b)
        if a < b:
            st.append((i+1, b - a))
        else:
            while st:
                k, x = st.pop()
                ans.append((k, "R", x))
            ans.append((i+1, "L", a - b))

    print(S)
    for k, s, x in ans:
        for _ in range(x):
            print(k, s)


if __name__ == '__main__':
    main()
0