結果
| 問題 |
No.193 筒の数式
|
| コンテスト | |
| ユーザー |
yoza
|
| 提出日時 | 2015-04-26 23:14:00 |
| 言語 | Nim (2.2.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 816 bytes |
| コンパイル時間 | 2,693 ms |
| コンパイル使用メモリ | 65,892 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-06-29 01:52:15 |
| 合計ジャッジ時間 | 3,574 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 11 WA * 5 |
コンパイルメッセージ
/home/judge/data/code/Main.nim(1, 8) Warning: imported and not used: 'strutils' [UnusedImport] /home/judge/data/code/Main.nim(1, 18) Warning: imported and not used: 'sequtils' [UnusedImport] /home/judge/data/code/Main.nim(1, 28) Warning: imported and not used: 'algorithm' [UnusedImport] /home/judge/data/code/Main.nim(1, 39) Warning: imported and not used: 'math' [UnusedImport]
ソースコード
import strutils, sequtils, algorithm, math
let
s = readLine(stdin)
ope = ['+', '-']
var
pre: int
preOpe: int
tmpResult = 0
maxResult = 0
for start in countup(0, s.len() - 1):
if s[start] in ope or s[(start + s.len() - 1) mod s.len()] in ope:
continue
pre = s[start].ord - 48
preOpe = -1
for ite in countup(start + 1, start + s.len() - 1):
if s[ite mod s.len()] in ope:
if preOpe == 0:
tmpResult += pre
elif preOpe == 1:
tmpResult -= pre
else:
tmpResult = pre
pre = 0
if s[ite mod s.len()] == '+':
preOpe = 0
else:
preOpe = 1
else:
pre = pre * 10 + s[ite mod s.len()].ord - 48
if preOpe == 0:
tmpResult += pre
else:
tmpResult -= pre
maxResult = max(tmpResult, maxResult)
echo maxResult
yoza