結果
| 問題 |
No.110 しましまピラミッド
|
| コンテスト | |
| ユーザー |
jj
|
| 提出日時 | 2016-08-11 20:59:09 |
| 言語 | Fortran (gFortran 14.2.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 1,688 bytes |
| コンパイル時間 | 2,143 ms |
| コンパイル使用メモリ | 36,224 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-12-31 11:22:49 |
| 合計ジャッジ時間 | 3,256 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 26 |
ソースコード
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
implicit none
interface
recursive function qsort(x) result(y)
integer,intent(in) ::x(:)
integer,allocatable::y(:)
end function qsort
end interface
integer::NW,NB
integer,allocatable::W(:),B(:)
integer,allocatable::WS(:),BS(:)
integer::i,j,top,itrw,itrb,maxw,maxb,height
read *,NW
allocate(W(NW),WS(NW))
read *,W
read *,NB
allocate(B(NB),BS(NB))
read *,B
WS = qsort(W)
BS = qsort(B)
top = BS(NB)
height = 1
do
do itrw=NW, 1,-1
if(WS(itrw).lt.top) then
top = WS(itrw)
height = 1 + height
exit
end if
end do
if(itrw.eq.0.) exit
do itrb=NB, 1,-1
if(BS(itrb).lt.top) then
top = BS(itrb)
height = 1 + height
exit
end if
end do
if(itrb.eq.0.) exit
end do
maxw = height
top = WS(NW)
height = 1
do
do itrb=NB, 1,-1
if(BS(itrb).lt.top) then
top = BS(itrb)
height = 1 + height
exit
end if
end do
if(itrb.eq.0.) exit
do itrw=NW, 1,-1
if(WS(itrw).lt.top) then
top = WS(itrw)
height = 1 + height
exit
end if
end do
if(itrw.eq.0.) exit
end do
maxb = height
print '(i0)', MAX(maxw,maxb)
end program main
jj