結果

問題 No.1767 BLUE to RED
ユーザー ygd.ygd.
提出日時 2021-12-02 21:23:39
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 1,067 bytes
コンパイル時間 92 ms
コンパイル使用メモリ 10,928 KB
実行使用メモリ 35,568 KB
最終ジャッジ日時 2023-09-18 10:38:25
合計ジャッジ時間 9,799 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,920 KB
testcase_01 AC 16 ms
7,740 KB
testcase_02 AC 16 ms
7,804 KB
testcase_03 AC 15 ms
7,844 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 16 ms
7,888 KB
testcase_07 AC 17 ms
7,740 KB
testcase_08 AC 17 ms
7,744 KB
testcase_09 AC 260 ms
23,344 KB
testcase_10 AC 339 ms
26,952 KB
testcase_11 AC 271 ms
25,204 KB
testcase_12 AC 259 ms
23,352 KB
testcase_13 WA -
testcase_14 AC 444 ms
35,496 KB
testcase_15 AC 448 ms
35,488 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 442 ms
35,396 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 445 ms
35,392 KB
testcase_23 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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()
0