結果
問題 | No.275 中央値を求めよ |
ユーザー |
|
提出日時 | 2020-06-05 18:02:09 |
言語 | Fortran (gFortran 14.2.0) |
結果 |
AC
|
実行時間 | 2 ms / 1,000 ms |
コード長 | 1,165 bytes |
コンパイル時間 | 2,494 ms |
コンパイル使用メモリ | 32,256 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-16 04:40:35 |
合計ジャッジ時間 | 4,081 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 38 |
ソースコード
program y275 implicit none integer(8)::N real(8),allocatable::A(:) read*,N allocate(A(N)) read*,A call heapsort(N,A) if(mod(N,2)==1)print*,A(N/2+1) if(mod(N,2)==0)print*,(A(N/2)+A(N/2+1))/2 end program y275 subroutine heapsort(n,array) implicit none integer(8),intent(in) :: n double precision,intent(inout) :: array(1:n) integer(8) ::i,k,j,l double precision :: t if(n.le.0)then write(6,*)"Error, at heapsort"; stop endif if(n.eq.1)return l=n/2+1 k=n do while(k.ne.1) if(l.gt.1)then l=l-1 t=array(L) else t=array(k) array(k)=array(1) k=k-1 if(k.eq.1) then array(1)=t exit endif endif i=l j=l+l do while(j.le.k) if(j.lt.k)then if(array(j).lt.array(j+1))j=j+1 endif if (t.lt.array(j))then array(i)=array(j) i=j j=j+j else j=k+1 endif enddo array(i)=t enddo return end subroutine heapsort