結果
| 問題 |
No.193 筒の数式
|
| コンテスト | |
| ユーザー |
jj
|
| 提出日時 | 2016-09-16 23:51:33 |
| 言語 | Fortran (gFortran 14.2.0) |
| 結果 |
AC
|
| 実行時間 | 1 ms / 1,000 ms |
| コード長 | 1,478 bytes |
| コンパイル時間 | 268 ms |
| コンパイル使用メモリ | 34,024 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-11-17 08:06:10 |
| 合計ジャッジ時間 | 1,116 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 16 |
ソースコード
program main
implicit none
character*10::S
character,allocatable::SS(:)
integer::len,i,j,head,tail
integer*8::num(5),opn,maxnum
data opn/0/,maxnum/-100000000/
read *,S
len = LEN_TRIM(S)
allocate(SS(len))
call string2array(S,SS)
do i=1,len
SS = CSHIFT(SS,1)
call array2string(S,SS)
if(is_valid(S).eqv..true.)then
num = 0
opn = 0
head = 1
do j=2,len-1
if(S(j:j).eq.'+'.or.S(j:j).eq.'-') then
tail = j - 1
opn = opn + 1
read(S(head:tail),*) num(opn)
head = j
end if
end do
tail = len
opn = opn + 1
read(S(head:tail),*) num(opn)
maxnum = MAX(maxnum, SUM(num(1:opn)))
end if
end do
print '(i0)', maxnum
contains
logical function is_valid(S) result(l)
character*10::S
integer::m
m = LEN_TRIM(S)
if(S(1:1).ne.'+'.and.S(1:1).ne.'-' .and. &
S(m:m).ne.'+'.and.S(m:m).ne.'-') then
l = .true.
else
l = .false.
end if
end function is_valid
subroutine string2array(S,SS)
implicit none
character::SS(:)
character*10::S
integer::i
do i=1,LEN_TRIM(S)
SS(i) = S(i:i)
end do
end subroutine string2array
subroutine array2string(S,SS)
implicit none
character::SS(:)
character*10::S
integer::i
do i=1,LEN_TRIM(S)
S(i:i) = SS(i)
end do
end subroutine array2string
end program main
jj