結果

問題 No.78 クジ付きアイスバー
ユーザー jj
提出日時 2016-10-04 22:57:21
言語 Fortran
(gFortran 14.2.0)
結果
WA  
実行時間 -
コード長 831 bytes
コンパイル時間 602 ms
コンパイル使用メモリ 32,000 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-21 16:56:22
合計ジャッジ時間 1,990 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 28 WA * 7
権限があれば一括ダウンロードができます

ソースコード

diff #

program main
  implicit none
  integer*8::N,K,atari,buy,total
  character*50::S
  integer::i
  data atari/0/,buy/0/
  read *,N,K
  read *,S(1:N)

  do i=1,MIN(N,K)
     if(atari.eq.0) then
        buy   = buy   + 1
     else
        atari = atari - 1
     end if
     atari = atari + ICHAR(S(i:i))-ICHAR('0')
  end do

  if(N.gt.K .or. atari.ge.buy) then
     print '(i0)', buy
     return
  end if

!  print *,"first:", buy, atari

  if((K-N-1)/N.ge.1) then
     total = buy + (buy - atari) * (K-N-1)/N
  else
     total = buy
  end if

!  print *,"second:", total, (K-N-1)/N

  buy = 0
  do i=1,(K-((K-N-1)/N+1)*N)
     if(atari.eq.0) then
        buy   = buy   + 1
     else
        atari = atari - 1
     end if
     atari = atari + ICHAR(S(i:i))-ICHAR('0')
  end do
  total = total + buy
  print '(i0)', total
end program main
0