結果
| 問題 |
No.1767 BLUE to RED
|
| コンテスト | |
| ユーザー |
ygd.
|
| 提出日時 | 2021-12-02 21:23:39 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,067 bytes |
| コンパイル時間 | 90 ms |
| コンパイル使用メモリ | 12,416 KB |
| 実行使用メモリ | 38,252 KB |
| 最終ジャッジ日時 | 2024-07-05 02:07:09 |
| 合計ジャッジ時間 | 10,480 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 12 WA * 9 |
ソースコード
import sys
#input = sys.stdin.readline #文字列につけてはダメ
input = sys.stdin.buffer.readline #文字列につけてはダメ
#sys.setrecursionlimit(1000000)
#import bisect
#import itertools
#import random
#from heapq import heapify, heappop, heappush
#from collections import defaultdict
#from collections import deque
#import copy
def main():
N,M = map(int,input().split()); INF = pow(10,18)
A = [0] + list(map(int,input().split())) + [INF]
B = list(map(int,input().split()))
ans = 0
j = 0
for i in range(N+1):
if j >= M: break
temp = []
left,right = A[i:i+2]
while j < M and B[j] < right:
temp.append(B[j])
j += 1
#print(temp,left,right)
L = [0]; R = [0]
for k in range(len(temp)):
L.append(temp[k] - left)
R.append(right - temp[-1-k])
R.reverse()
#print(L,R)
mn = INF
for p,q in zip(L,R):
mn = min(mn, p+q)
ans += mn
print(ans)
if __name__ == '__main__':
main()
ygd.