結果

問題 No.370 道路の掃除
コンテスト
ユーザー organ05
提出日時 2016-05-16 11:46:37
言語 PyPy2
(7.3.20)
コンパイル:
pypy2 -m py_compile _filename_
実行:
/usr/bin/pypy2 Main.pyc
結果
WA  
実行時間 -
コード長 452 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 58 ms
コンパイル使用メモリ 80,532 KB
実行使用メモリ 83,748 KB
最終ジャッジ日時 2026-07-18 06:15:40
合計ジャッジ時間 4,045 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
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