結果
問題 | No.1650 Moving Coins |
ユーザー | moharan627 |
提出日時 | 2021-08-20 22:00:29 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
AC
|
実行時間 | 507 ms / 2,000 ms |
コード長 | 1,785 bytes |
コンパイル時間 | 202 ms |
コンパイル使用メモリ | 10,852 KB |
実行使用メモリ | 63,724 KB |
最終ジャッジ日時 | 2023-08-04 06:30:40 |
合計ジャッジ時間 | 12,210 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge15 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 19 ms
8,640 KB |
testcase_01 | AC | 19 ms
8,596 KB |
testcase_02 | AC | 19 ms
8,696 KB |
testcase_03 | AC | 209 ms
22,240 KB |
testcase_04 | AC | 164 ms
18,964 KB |
testcase_05 | AC | 199 ms
21,328 KB |
testcase_06 | AC | 216 ms
22,492 KB |
testcase_07 | AC | 218 ms
22,684 KB |
testcase_08 | AC | 350 ms
47,000 KB |
testcase_09 | AC | 347 ms
43,376 KB |
testcase_10 | AC | 370 ms
48,148 KB |
testcase_11 | AC | 374 ms
47,224 KB |
testcase_12 | AC | 301 ms
37,708 KB |
testcase_13 | AC | 307 ms
38,644 KB |
testcase_14 | AC | 348 ms
44,280 KB |
testcase_15 | AC | 288 ms
34,908 KB |
testcase_16 | AC | 396 ms
48,488 KB |
testcase_17 | AC | 381 ms
48,324 KB |
testcase_18 | AC | 416 ms
53,008 KB |
testcase_19 | AC | 504 ms
63,724 KB |
testcase_20 | AC | 487 ms
62,236 KB |
testcase_21 | AC | 499 ms
62,696 KB |
testcase_22 | AC | 498 ms
62,224 KB |
testcase_23 | AC | 507 ms
62,240 KB |
testcase_24 | AC | 222 ms
22,832 KB |
testcase_25 | AC | 220 ms
22,712 KB |
testcase_26 | AC | 249 ms
41,516 KB |
ソースコード
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)#再帰関数ではコメントにしないこと!!