結果

問題 No.1508 Avoid being hit
ユーザー convexineqconvexineq
提出日時 2021-05-15 12:57:58
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 197 ms / 3,000 ms
コード長 638 bytes
コンパイル時間 214 ms
コンパイル使用メモリ 82,396 KB
実行使用メモリ 106,212 KB
最終ジャッジ日時 2024-04-14 03:38:16
合計ジャッジ時間 7,143 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 130 ms
100,568 KB
testcase_01 AC 39 ms
52,656 KB
testcase_02 AC 39 ms
53,256 KB
testcase_03 AC 39 ms
52,820 KB
testcase_04 AC 38 ms
53,076 KB
testcase_05 AC 38 ms
52,280 KB
testcase_06 AC 38 ms
52,560 KB
testcase_07 AC 38 ms
52,264 KB
testcase_08 AC 37 ms
52,316 KB
testcase_09 AC 37 ms
53,436 KB
testcase_10 AC 37 ms
53,372 KB
testcase_11 AC 39 ms
53,228 KB
testcase_12 AC 38 ms
52,996 KB
testcase_13 AC 38 ms
52,136 KB
testcase_14 AC 37 ms
53,484 KB
testcase_15 AC 38 ms
52,928 KB
testcase_16 AC 106 ms
102,964 KB
testcase_17 AC 85 ms
89,520 KB
testcase_18 AC 79 ms
84,496 KB
testcase_19 AC 98 ms
99,524 KB
testcase_20 AC 112 ms
102,604 KB
testcase_21 AC 97 ms
96,736 KB
testcase_22 AC 106 ms
103,412 KB
testcase_23 AC 109 ms
103,776 KB
testcase_24 AC 182 ms
106,212 KB
testcase_25 AC 197 ms
102,660 KB
testcase_26 AC 103 ms
77,356 KB
testcase_27 AC 144 ms
87,632 KB
testcase_28 AC 152 ms
87,908 KB
testcase_29 AC 185 ms
103,216 KB
testcase_30 AC 164 ms
89,208 KB
testcase_31 AC 176 ms
99,320 KB
testcase_32 AC 172 ms
102,452 KB
testcase_33 AC 132 ms
80,472 KB
testcase_34 AC 123 ms
97,564 KB
testcase_35 AC 66 ms
73,216 KB
testcase_36 AC 95 ms
86,588 KB
testcase_37 AC 82 ms
78,124 KB
testcase_38 AC 114 ms
92,616 KB
testcase_39 AC 102 ms
86,268 KB
testcase_40 AC 134 ms
100,072 KB
testcase_41 AC 97 ms
88,396 KB
testcase_42 AC 128 ms
100,448 KB
testcase_43 AC 128 ms
104,552 KB
testcase_44 AC 39 ms
52,648 KB
testcase_45 AC 38 ms
53,268 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n,Q = map(int,input().split())
*a, = map(int,input().split())
*b, = map(int,input().split())
L = [0]*Q
R = [0]*Q
l,r = 1,n

def check(v,a,b):
    return (v != a and v != b) and not(v-1 in lst and v in lst and v+1 in lst)

for i in range(Q)[::-1]:
    lst = [l-1,l-2,r+1,r+2]
    for l in range(max(l-1,1),l+3):
        if check(l,a[i],b[i]): break
    for r in range(min(n,r+1),r-3,-1):
        if check(r,a[i],b[i]): break
    L[i], R[i] = l,r
    if l > r:
        print("NO")
        exit()

print("YES")
print(l)
for i in range(Q):
    for l in [l-1,l,l+1]:
        if L[i] <= l <= R[i] and l != a[i] and l != b[i]: break
    print(l)
0