結果

問題 No.3308 One-time Changed Formula
コンテスト
ユーザー cologne
提出日時 2025-11-14 15:07:01
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 105 ms / 2,000 ms
コード長 641 bytes
コンパイル時間 384 ms
コンパイル使用メモリ 82,504 KB
実行使用メモリ 76,892 KB
最終ジャッジ日時 2025-11-14 15:07:04
合計ジャッジ時間 3,317 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 15
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys


def input(): return sys.stdin.readline().rstrip('\n')


def main():
    t = int(input())
    for _ in range(t):
        input()
        f = input()

        plus = True
        ans = 0
        for c in f:
            if c in ['+', '-', '*']:
                if plus:
                    ans += 9
                if c == '+':
                    plus = True
                if c == '-':
                    plus = False
            else:
                if plus:
                    ans += 9 - int(c)
                else:
                    ans += max(0, int(c) - 1)

        print(ans)


if __name__ == '__main__':
    main()
0