結果
問題 |
No.390 最長の数列
|
ユーザー |
![]() |
提出日時 | 2016-08-10 23:46:00 |
言語 | Fortran (gFortran 14.2.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 947 bytes |
コンパイル時間 | 1,487 ms |
コンパイル使用メモリ | 34,928 KB |
実行使用メモリ | 11,840 KB |
最終ジャッジ日時 | 2024-11-07 10:37:12 |
合計ジャッジ時間 | 8,425 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 1 TLE * 1 -- * 13 |
ソースコード
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::N,i,j,max_len,tmp, tmp2 integer,allocatable::x(:),y(:),dp(:) read *, N allocate(x(N),y(N),dp(N)) read *, x y = qsort(x) ! max length of good series @ index num dp = 1 do i=2, N max_len = 0 do j=1,i-1 if(MOD(y(i),y(j)).eq.0) then max_len = MAX(max_len, dp(j)) end if end do dp(i) = max_len + 1 end do print '(i0)', MAXVAL(dp) end program main