結果

問題 No.204 ゴールデン・ウィーク(2)
ユーザー jj
提出日時 2016-09-01 23:38:56
言語 Fortran
(gFortran 14.2.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 761 bytes
コンパイル時間 1,952 ms
コンパイル使用メモリ 33,144 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-12-24 11:56:49
合計ジャッジ時間 3,172 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 46
権限があれば一括ダウンロードができます

ソースコード

diff #

program main
  implicit none
  integer::N,i,j,M
  character*14::a
  integer::days(-13:28)
  integer::days2(-13:28)
  data days/42*0/
  read *,N
  read *,a(1:7),a(8:14)

  do i=1,14
     if(a(i:i).eq.'o') days(i) = 1
  end do

  M = 0
  do i=-13,15
     if(days(i).eq.0) continue

     days2 = days
     do j=i,i+N-1
        if(days(j).eq.1) exit
        days2(j) = 1
     end do
     M = MAX(M,get_longest(days2))
  end do

  print '(i0)', M
contains
  function get_longest(days2) result(L)
    integer::days2(-13:27),L,M
    integer::i
    L = 0
    M = 0
    do i=-13,28
       if(days2(i).eq.1) then
          M = M + 1
       else
          L = MAX(L,M)
          M = 0
       end if
    end do
    L = MAX(L,M)

  end function get_longest
end program main
0