結果

問題 No.45 回転寿司
ユーザー jjjj
提出日時 2016-07-23 14:42:19
言語 Fortran
(gFortran 13.2.0)
結果
WA  
実行時間 -
コード長 1,786 bytes
コンパイル時間 1,172 ms
コンパイル使用メモリ 31,360 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-05-03 15:28:02
合計ジャッジ時間 2,049 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 1 ms
5,376 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 1 ms
5,376 KB
testcase_23 AC 2 ms
5,376 KB
testcase_24 AC 1 ms
5,376 KB
testcase_25 AC 1 ms
5,376 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 1 ms
5,376 KB
testcase_32 AC 1 ms
5,376 KB
testcase_33 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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
0