結果
問題 | No.135 とりあえず1次元の問題 |
ユーザー |
![]() |
提出日時 | 2016-07-28 16:38:37 |
言語 | Fortran (gFortran 14.2.0) |
結果 |
AC
|
実行時間 | 68 ms / 5,000 ms |
コード長 | 916 bytes |
コンパイル時間 | 349 ms |
コンパイル使用メモリ | 35,324 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-11 06:52:36 |
合計ジャッジ時間 | 2,085 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 22 |
ソースコード
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 program main interface recursive function qsort(x) result(y) integer,intent(in) ::x(:) integer,allocatable::y(:) end function qsort end interface integer,parameter::initdist=1000001 integer::N,i,mindist=initdist integer,allocatable::X(:) integer,allocatable::Y(:) read *,N allocate(X(N)) allocate(Y(N)) read *,X Y=qsort(X) do i=1,N-1 if(Y(i).eq.Y(i+1)) cycle mindist = MIN(mindist, Y(i+1)-Y(i)) if(mindist.eq.1) exit end do if(mindist.eq.initdist) mindist=0 print '(i0)', mindist end program main