結果
問題 | No.1888 Odd Insertion |
ユーザー |
![]() |
提出日時 | 2025-06-12 21:34:18 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,592 bytes |
コンパイル時間 | 279 ms |
コンパイル使用メモリ | 82,224 KB |
実行使用メモリ | 125,740 KB |
最終ジャッジ日時 | 2025-06-12 21:35:15 |
合計ジャッジ時間 | 11,630 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 14 WA * 10 TLE * 1 -- * 12 |
ソースコード
import bisect def main(): import sys input = sys.stdin.read data = input().split() N = int(data[0]) P = list(map(int, data[1:N+1])) A = P.copy() current_S = [] operations = [] for i in range(N, 0, -1): found = False max_y = min(i, len(A)) # First, check for odd y in descending order for y in range(max_y, 0, -1): if y % 2 == 1: if y-1 >= len(A): continue x = A[y-1] idx = bisect.bisect_left(current_S, x) if idx == 0 or (idx == 1 and len(current_S) >= 1): A.pop(y-1) bisect.insort(current_S, x) operations.append((x, y)) found = True break if not found: # Check all y in descending order for y in range(max_y, 0, -1): if y-1 >= len(A): continue x = A[y-1] idx = bisect.bisect_left(current_S, x) if idx == 0 or (idx == 1 and len(current_S) >= 1): A.pop(y-1) bisect.insort(current_S, x) operations.append((x, y)) found = True break if not found: print("No") return # Reverse the operations to get the correct order operations = operations[::-1] print("Yes") for x, y in operations: print(x, y) if __name__ == "__main__": main()