結果
問題 |
No.5 数字のブロック
|
ユーザー |
![]() |
提出日時 | 2016-07-22 13:44:44 |
言語 | Fortran (gFortran 14.2.0) |
結果 |
AC
|
実行時間 | 8 ms / 5,000 ms |
コード長 | 938 bytes |
コンパイル時間 | 672 ms |
コンパイル使用メモリ | 35,316 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-11-18 08:48:02 |
合計ジャッジ時間 | 1,799 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 34 |
ソースコード
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::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