結果

問題 No.1913 Periodic Comparison
ユーザー chineristACchineristAC
提出日時 2022-01-06 10:53:46
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 298 ms / 2,000 ms
コード長 791 bytes
コンパイル時間 445 ms
コンパイル使用メモリ 87,024 KB
実行使用メモリ 129,556 KB
最終ジャッジ日時 2023-09-02 06:55:34
合計ジャッジ時間 20,870 ms
ジャッジサーバーID
(参考情報)
judge13 / judge16
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 107 ms
74,748 KB
testcase_01 AC 109 ms
74,572 KB
testcase_02 AC 148 ms
88,524 KB
testcase_03 AC 110 ms
74,876 KB
testcase_04 AC 110 ms
74,444 KB
testcase_05 AC 106 ms
74,584 KB
testcase_06 AC 109 ms
74,788 KB
testcase_07 AC 110 ms
74,784 KB
testcase_08 AC 180 ms
97,152 KB
testcase_09 AC 294 ms
128,344 KB
testcase_10 AC 183 ms
97,656 KB
testcase_11 AC 297 ms
128,556 KB
testcase_12 AC 223 ms
127,964 KB
testcase_13 AC 182 ms
97,192 KB
testcase_14 AC 245 ms
128,444 KB
testcase_15 AC 294 ms
128,724 KB
testcase_16 AC 248 ms
128,608 KB
testcase_17 AC 188 ms
97,400 KB
testcase_18 AC 181 ms
97,788 KB
testcase_19 AC 293 ms
128,840 KB
testcase_20 AC 233 ms
128,356 KB
testcase_21 AC 293 ms
128,684 KB
testcase_22 AC 153 ms
89,132 KB
testcase_23 AC 180 ms
96,860 KB
testcase_24 AC 298 ms
128,668 KB
testcase_25 AC 221 ms
128,224 KB
testcase_26 AC 244 ms
128,432 KB
testcase_27 AC 181 ms
97,752 KB
testcase_28 AC 182 ms
97,328 KB
testcase_29 AC 297 ms
128,716 KB
testcase_30 AC 253 ms
128,256 KB
testcase_31 AC 180 ms
96,836 KB
testcase_32 AC 176 ms
96,908 KB
testcase_33 AC 161 ms
97,192 KB
testcase_34 AC 292 ms
128,720 KB
testcase_35 AC 290 ms
128,528 KB
testcase_36 AC 215 ms
128,012 KB
testcase_37 AC 289 ms
128,328 KB
testcase_38 AC 106 ms
74,872 KB
testcase_39 AC 106 ms
74,728 KB
testcase_40 AC 281 ms
129,204 KB
testcase_41 AC 287 ms
129,284 KB
testcase_42 AC 277 ms
129,556 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys,random,bisect
from collections import deque,defaultdict


input = lambda :sys.stdin.readline().rstrip()
mi = lambda :map(int,input().split())
li = lambda :list(mi())

N = int(input())
X = li()
Y = li()

M = max(Y)
f_inv = [-1] * (M+1)
for i in range(N):
    f_inv[Y[i]] = N * X[i] + i

deq = deque([-1]*N)
for i in range(M+1)[::-1]:
    if not deq:
        exit(print(-1))
    v = deq.popleft()
    if f_inv[i]==-1:
        f_inv[i] = v
    else:
        if v!=-1 and v!=f_inv[i]:
            exit(print(-1))
        elif v==-1:
            v = f_inv[i]
    
    if v==-1:
        deq.append(v)
    elif N <= v:
        deq.append(v-N)
if deq:
    exit(print(-1))
    
ans = [0] * N
for i in range(M+1):
    if f_inv[i] < N and f_inv[i]!=-1:
        ans[f_inv[i]] = i

print(*ans)
0