結果
問題 | 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 y275implicit noneinteger(8)::Nreal(8),allocatable::A(:)read*,Nallocate(A(N))read*,Acall 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))/2end program y275subroutine heapsort(n,array)implicit noneinteger(8),intent(in) :: ndouble precision,intent(inout) :: array(1:n)integer(8) ::i,k,j,ldouble precision :: tif(n.le.0)thenwrite(6,*)"Error, at heapsort"; stopendifif(n.eq.1)returnl=n/2+1k=ndo while(k.ne.1)if(l.gt.1)thenl=l-1t=array(L)elset=array(k)array(k)=array(1)k=k-1if(k.eq.1) thenarray(1)=texitendifendifi=lj=l+ldo while(j.le.k)if(j.lt.k)thenif(array(j).lt.array(j+1))j=j+1endifif (t.lt.array(j))thenarray(i)=array(j)i=jj=j+jelsej=k+1endifenddoarray(i)=tenddoreturnend subroutine heapsort