結果
問題 | No.5 数字のブロック |
ユーザー | jj |
提出日時 | 2016-07-22 13:43:00 |
言語 | Fortran (gFortran 14.2.0) |
結果 |
AC
|
実行時間 | 6 ms / 5,000 ms |
コード長 | 869 bytes |
コンパイル時間 | 1,483 ms |
コンパイル使用メモリ | 35,068 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-18 08:46:27 |
合計ジャッジ時間 | 2,101 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 34 |
ソースコード
module qsort_mod 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 module qsort_mod program main use qsort_mod integer::i integer::box_width,block_num,total_width integer,allocatable::input(:), sorted(:) read *,box_width,block_num allocate(input(block_num)) allocate(sorted(block_num)) read *,input sorted = qsort(input) total_width = 0 do i=1,block_num total_width=total_width+sorted(i) if ( total_width.gt.box_width ) then exit endif end do print '(i0)', i-1 end program main