結果
問題 | No.193 筒の数式 |
ユーザー |
![]() |
提出日時 | 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 mainimplicit nonecharacter*10::Scharacter,allocatable::SS(:)integer::len,i,j,head,tailinteger*8::num(5),opn,maxnumdata opn/0/,maxnum/-100000000/read *,Slen = LEN_TRIM(S)allocate(SS(len))call string2array(S,SS)do i=1,lenSS = CSHIFT(SS,1)call array2string(S,SS)if(is_valid(S).eqv..true.)thennum = 0opn = 0head = 1do j=2,len-1if(S(j:j).eq.'+'.or.S(j:j).eq.'-') thentail = j - 1opn = opn + 1read(S(head:tail),*) num(opn)head = jend ifend dotail = lenopn = opn + 1read(S(head:tail),*) num(opn)maxnum = MAX(maxnum, SUM(num(1:opn)))end ifend doprint '(i0)', maxnumcontainslogical function is_valid(S) result(l)character*10::Sinteger::mm = LEN_TRIM(S)if(S(1:1).ne.'+'.and.S(1:1).ne.'-' .and. &S(m:m).ne.'+'.and.S(m:m).ne.'-') thenl = .true.elsel = .false.end ifend function is_validsubroutine string2array(S,SS)implicit nonecharacter::SS(:)character*10::Sinteger::ido i=1,LEN_TRIM(S)SS(i) = S(i:i)end doend subroutine string2arraysubroutine array2string(S,SS)implicit nonecharacter::SS(:)character*10::Sinteger::ido i=1,LEN_TRIM(S)S(i:i) = SS(i)end doend subroutine array2stringend program main