結果

問題 No.370 道路の掃除
コンテスト
ユーザー organ05
提出日時 2016-05-16 11:46:37
言語 PyPy2
(7.3.15)
結果
WA  
実行時間 -
コード長 452 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 140 ms
コンパイル使用メモリ 77,600 KB
最終ジャッジ日時 2025-12-03 20:45:57
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 10 WA * 24
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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