結果

問題 No.1268 Fruit Rush 2
ユーザー hanyu
提出日時 2020-05-31 23:34:11
言語 Fortran
(gFortran 14.2.0)
結果
RE  
実行時間 -
コード長 600 bytes
コンパイル時間 2,712 ms
コンパイル使用メモリ 32,128 KB
実行使用メモリ 13,756 KB
最終ジャッジ日時 2024-06-22 07:43:50
合計ジャッジ時間 4,977 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 19 RE * 9 TLE * 1 -- * 4
権限があれば一括ダウンロードができます

ソースコード

diff #

! 愚直パターン
program main
  
  implicit none
  
  integer(8):: n, i, ans, it, keep
  integer:: x(1:200000)
  integer, allocatable:: a(:)
  
  read (*, *) n
  allocate(a(n))
  read (*, *) a(1:n)
  
  do i = 1, n
    x(a(i)) = 1
  end do
  
  ans = n
  do i = 2, 200000
    if (x(i - 1) > 0 .and. x(i) > 0) then
      it = i
      keep = 1
      do while (it < 199999)
        if (x(it + 2) > 0) then
          keep = keep + 1
          it = it + 2
        else
          exit
        end if
      end do
      ans = ans + keep
    end if
  end do
  
  write (*, '(i0)') ans
  
end program main
0