結果
| 問題 | No.370 道路の掃除 |
| コンテスト | |
| ユーザー |
jj
|
| 提出日時 | 2016-09-11 16:39:01 |
| 言語 | Fortran (gFortran 15.2.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 826 bytes |
| 記録 | |
| コンパイル時間 | 336 ms |
| コンパイル使用メモリ | 35,156 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-17 03:27:58 |
| 合計ジャッジ時間 | 1,524 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 30 WA * 4 |
ソースコード
program main
implicit none
integer::N,M,minimum,i,j
integer,allocatable::D(:),DD(:)
read *,N,M
allocate(D(M),DD(M))
read *,D
DD = qsort(D)
minimum = 30000
do i=1,M-N+1
j = i+N-1
if(D(i)*D(j).ge.0) then
minimum = MIN(minimum, MAX(ABS(D(i)),ABS(D(j))))
else
minimum = MIN(minimum, ABS(D(i))+ABS(D(j)) + MIN(ABS(D(i)),ABS(D(j))))
end if
end do
print '(i0)',minimum
contains
recursive function qsort(x) result(y)
integer,intent(in) ::x(:)
integer,allocatable::y(:)
integer::pivot,total
total = size(x)
if (total <=1) then
y = x
else
pivot = x(total/2)
y = [qsort(pack(x, x .lt. pivot)), &
pack(x, x .eq. pivot), &
qsort(pack(x, x .gt. pivot))]
endif
end function qsort
end program main
jj