結果
問題 |
No.45 回転寿司
|
ユーザー |
![]() |
提出日時 | 2016-07-23 14:42:19 |
言語 | Fortran (gFortran 14.2.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,786 bytes |
コンパイル時間 | 349 ms |
コンパイル使用メモリ | 32,384 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-11-24 17:12:26 |
合計ジャッジ時間 | 1,316 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 3 WA * 27 |
ソースコード
recursive function get_max(part, length) result(res) implicit none integer::part(*) integer::length,x,y integer::res(2,2),first(2,2),second(2,2) integer::plength integer,parameter::on=1,off=2 if (length.ge.3) then plength = length/2 first = get_max(part(1:plength),plength) second = get_max(part(plength+1:length),length-plength) res(on,on) = MAXVAL((/first(on,off)+second(off,on), & first(on,off)+second(on, on), & first(on, on)+second(off,on)/)) res(on,off) = MAXVAL((/first(on,off)+second(off,off), & first(on,off)+second(on, off), & first(on, on)+second(off,off)/)) res(off,on) = MAXVAL((/first(off,off)+second(off,on), & first(off,off)+second(on, on), & first(off, on)+second(off,on)/)) res(off,off) = MAXVAL((/first(off,off)+second(off,off), & first(off,off)+second(on, off), & first(off, on)+second(off,off)/)) else if(length.eq.2) then res(on,on) = MAX(part(1),part(2)) res(on,off) = part(1) res(off,on) = part(2) res(off,off) = 0 else if(length.eq.1) then res(on,on) = part(1) res(on,off) = 0 res(off,on) = part(1) res(off,off) = 0 end if end function get_max program main implicit none interface recursive function get_max(part, length) result(res) integer::part(*) integer::length integer::res(2,2) end function get_max end interface integer::N integer::oisisa(2,2) integer::V(1000) read *, N read *, V(1:N) oisisa = get_max(V(1:N),N) print '(i0)',MAXVAL(oisisa) end program main