結果

問題 No.1950 片道きゃっちぼーる
ユーザー siganai
提出日時 2022-05-20 23:21:50
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 794 bytes
コンパイル時間 533 ms
コンパイル使用メモリ 82,092 KB
実行使用メモリ 147,120 KB
最終ジャッジ日時 2024-09-20 09:45:08
合計ジャッジ時間 9,752 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 16 WA * 7
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env PyPy3

from collections import Counter, defaultdict, deque
import itertools
import re
import math
from functools import reduce
import operator
import bisect
from heapq import *
import functools

mod=998244353

import sys
input=sys.stdin.readline
n=int(input())
x=list(map(int,input().split()))
a=list(map(int,input().split()))
p = [i for i in range(n)]
p.sort(key = lambda y:x[y]+a[y],reverse = True)
ans = [-1] * n
for pp in p:
    ans[pp] = x[pp] + a[pp]
    idx = bisect.bisect_right(x,x[pp] + a[pp])
    if x[idx-1] == x[pp] + a[pp]:
        ans[pp] = max(ans[pp],ans[idx-1])
    idx = bisect.bisect_right(x,x[pp] - a[pp])
    if idx == 0:
        continue
    if x[idx-1] == x[pp] - a[pp]:
        ans[pp] = max(ans[pp],ans[idx-1])
for i in range(n):
    print(ans[i]-x[i])
0