結果
| 問題 |
No.390 最長の数列
|
| コンテスト | |
| ユーザー |
jj
|
| 提出日時 | 2016-08-11 00:05:50 |
| 言語 | Fortran (gFortran 14.2.0) |
| 結果 |
AC
|
| 実行時間 | 79 ms / 5,000 ms |
| コード長 | 998 bytes |
| コンパイル時間 | 1,859 ms |
| コンパイル使用メモリ | 35,376 KB |
| 実行使用メモリ | 8,608 KB |
| 最終ジャッジ日時 | 2024-10-02 11:55:20 |
| 合計ジャッジ時間 | 3,134 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 15 |
ソースコード
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,max_val
integer,allocatable::x(:),y(:)
integer::dp(10**6)
data dp/1000000*0/
read *, N
allocate(x(N),y(N))
read *, x
y = qsort(x)
max_val = y(N)
do i=1,N
dp(y(i)) = 1
end do
max_len = 1
do i=1,N
tmp = y(i)
tmp2 = dp(y(i))
do j = tmp+tmp, max_val, tmp
dp(j) = MAX(dp(j), tmp2 + 1)
end do
max_len = MAX(max_len, dp(y(i)))
end do
print '(i0)', max_len
end program main
jj