結果

問題 No.1650 Moving Coins
ユーザー moharan627moharan627
提出日時 2021-08-20 22:00:29
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 611 ms / 2,000 ms
コード長 1,785 bytes
コンパイル時間 683 ms
コンパイル使用メモリ 12,928 KB
実行使用メモリ 65,992 KB
最終ジャッジ日時 2024-04-22 04:34:36
合計ジャッジ時間 14,501 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
10,880 KB
testcase_01 AC 30 ms
10,880 KB
testcase_02 AC 30 ms
10,880 KB
testcase_03 AC 283 ms
24,576 KB
testcase_04 AC 221 ms
21,248 KB
testcase_05 AC 264 ms
23,552 KB
testcase_06 AC 289 ms
24,832 KB
testcase_07 AC 291 ms
24,960 KB
testcase_08 AC 436 ms
49,312 KB
testcase_09 AC 435 ms
45,376 KB
testcase_10 AC 466 ms
50,460 KB
testcase_11 AC 467 ms
49,424 KB
testcase_12 AC 385 ms
40,168 KB
testcase_13 AC 392 ms
41,180 KB
testcase_14 AC 441 ms
46,740 KB
testcase_15 AC 364 ms
37,252 KB
testcase_16 AC 483 ms
51,168 KB
testcase_17 AC 472 ms
49,136 KB
testcase_18 AC 508 ms
53,076 KB
testcase_19 AC 610 ms
65,992 KB
testcase_20 AC 587 ms
64,308 KB
testcase_21 AC 611 ms
65,176 KB
testcase_22 AC 602 ms
64,212 KB
testcase_23 AC 602 ms
64,220 KB
testcase_24 AC 294 ms
25,216 KB
testcase_25 AC 296 ms
25,216 KB
testcase_26 AC 296 ms
43,836 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
INF = float('inf')
#10**20,2**63,float('inf')
MOD = 10**9 + 7
MOD2 = 998244353
#from collections import defaultdict
def solve():
    def II(): return int(sys.stdin.readline())
    def LI(): return list(map(int, sys.stdin.readline().split()))
    def LC(): return list(input())
    def IC(): return [int(c) for c in input()]
    def MI(): return map(int, sys.stdin.readline().split())
    N = II()
    A = LI()
    B = LI()
    Go = [[0,0] for _ in range(N)]
    for n in range(N):
        if A[n] < B[n]:
            Go[n][0] = "R"
            Go[n][1] = B[n]-A[n]
        elif A[n] > B[n]:
            Go[n][0] = "L"
            Go[n][1] = A[n] - B[n]
    #print(Go)
    i = 0
    from collections import deque
    Ope = deque()
    Num = 0
    Out = []
    while i < N:
        if Go[i][0] == "R":
            Ope.appendleft((i+1,"R",Go[i][1]))
        elif Go[i][0] == "L":
            while Ope:
                tmp = Ope.popleft()
                for _ in range(tmp[2]):
                    Num += 1
                    Out.append((tmp[0],tmp[1]))
                    #print(tmp[0],tmp[1])
            for _ in range(Go[i][1]):
                Num += 1
                Out.append((i+1,"L"))
        else:
            while Ope:
                tmp = Ope.popleft()
                for _ in range(tmp[2]):
                    Num += 1
                    Out.append((tmp[0],tmp[1]))
                    #print(tmp[0],tmp[1])
        i+=1
    while Ope:
        tmp = Ope.popleft()
        for _ in range(tmp[2]):
            Num += 1
            Out.append((tmp[0], tmp[1]))
            # print(tmp[0],tmp[1])
    print(Num)
    for out in Out:
        print(*out)
    return
solve()
#sys.setrecursionlimit(10 ** 6)#再帰関数ではコメントにしないこと!!
0