結果
| 問題 |
No.370 道路の掃除
|
| コンテスト | |
| ユーザー |
jj
|
| 提出日時 | 2016-09-11 16:40:38 |
| 言語 | Fortran (gFortran 14.2.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 833 bytes |
| コンパイル時間 | 1,036 ms |
| コンパイル使用メモリ | 35,272 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-17 03:28:38 |
| 合計ジャッジ時間 | 1,455 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 34 |
ソースコード
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(DD(i)*DD(j).ge.0) then
minimum = MIN(minimum, MAX(ABS(DD(i)),ABS(DD(j))))
else
minimum = MIN(minimum, ABS(DD(i))+ABS(DD(j)) + MIN(ABS(DD(i)),ABS(DD(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