結果

問題 No.370 道路の掃除
ユーザー organ05
提出日時 2016-05-16 11:46:37
言語 Python2
(2.7.18)
結果
WA  
実行時間 -
コード長 452 bytes
コンパイル時間 118 ms
コンパイル使用メモリ 6,912 KB
実行使用メモリ 6,656 KB
最終ジャッジ日時 2024-10-06 04:21:56
合計ジャッジ時間 2,513 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 10 WA * 24
権限があれば一括ダウンロードができます

ソースコード

diff #

import math
N, M = map(int,raw_input().split())
Dm = []
count = 0
position = 0
cost = 0



for i in range(M):
	Dm.append(input())

while count < N:
	for i in range(len(Dm)):
		if i == 0:
			dif = math.fabs(position - Dm[i])
			temp1 = Dm[i]
			temp2 = i

		else:
			if(dif > math.fabs(position - Dm[i])):
				dif = math.fabs(position - Dm[i])
				temp1 = Dm[i]
				temp2 = i

	del Dm[temp2]
	cost += dif
	position = temp1
	count += 1

print int(cost)

0