結果

問題 No.884 Eat and Add
ユーザー 6soukiti296soukiti29
提出日時 2019-09-13 22:02:37
言語 Nim
(2.0.2)
結果
AC  
実行時間 5 ms / 1,000 ms
コード長 481 bytes
コンパイル時間 4,980 ms
コンパイル使用メモリ 67,296 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-17 14:21:40
合計ジャッジ時間 5,246 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 5 ms
4,380 KB
testcase_04 AC 5 ms
4,376 KB
testcase_05 AC 4 ms
4,380 KB
testcase_06 AC 4 ms
4,376 KB
testcase_07 AC 3 ms
4,380 KB
testcase_08 AC 3 ms
4,380 KB
testcase_09 AC 4 ms
4,376 KB
testcase_10 AC 1 ms
4,384 KB
testcase_11 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
/home/judge/data/code/Main.nim(1, 8) Warning: imported and not used: 'sequtils' [UnusedImport]
/home/judge/data/code/Main.nim(1, 17) Warning: imported and not used: 'strutils' [UnusedImport]

ソースコード

diff #

import sequtils,strutils
var
    N = "0" & stdin.readline
    f : bool
    cnt = 0
for i in countdown(N.high, 1):
    if N[i] == '1':
        if f == true and N[i - 1] == '1':
            continue
        elif f == false and N[i - 1] == '1':
            f = true
            cnt += 1
        elif f == true and N[i - 1] == '0':
            N[i - 1] = '1'
            f = false
        elif f == false and N[i - 1] == '0':
            cnt += 1
if N[0] == '1':
    cnt += 1
echo cnt
0