結果

問題 No.910 素数部分列
ユーザー mbanmban
提出日時 2019-10-18 21:39:23
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 2,711 bytes
コンパイル時間 2,935 ms
コンパイル使用メモリ 106,244 KB
実行使用メモリ 25,192 KB
最終ジャッジ日時 2023-09-07 21:39:45
合計ジャッジ時間 8,115 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 58 ms
20,820 KB
testcase_01 AC 57 ms
20,736 KB
testcase_02 AC 58 ms
22,824 KB
testcase_03 AC 57 ms
20,824 KB
testcase_04 AC 58 ms
20,684 KB
testcase_05 AC 57 ms
20,816 KB
testcase_06 AC 59 ms
20,864 KB
testcase_07 AC 59 ms
22,684 KB
testcase_08 AC 60 ms
22,852 KB
testcase_09 AC 59 ms
18,672 KB
testcase_10 AC 61 ms
22,752 KB
testcase_11 AC 58 ms
20,800 KB
testcase_12 AC 58 ms
22,832 KB
testcase_13 WA -
testcase_14 AC 59 ms
22,744 KB
testcase_15 WA -
testcase_16 AC 59 ms
20,768 KB
testcase_17 WA -
testcase_18 AC 61 ms
22,716 KB
testcase_19 AC 60 ms
22,844 KB
testcase_20 WA -
testcase_21 AC 59 ms
20,732 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 AC 62 ms
20,964 KB
testcase_44 AC 63 ms
20,980 KB
testcase_45 WA -
testcase_46 WA -
testcase_47 WA -
testcase_48 AC 60 ms
21,020 KB
testcase_49 AC 60 ms
20,888 KB
testcase_50 AC 61 ms
20,992 KB
testcase_51 AC 61 ms
23,000 KB
testcase_52 AC 63 ms
22,996 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Text;

public class Program
{
    public void Solve()
    {
        var sc = new Scanner();
        int N = sc.NextInt();
        string S = sc.Next();

        int ans = 0;
        int oneCnt = 0;
        foreach (var c in S)
        {
            if (c == '3' || c == '5' || c == '7')
            {
                ans++;
            }
            else if (c == '1')
            {
                oneCnt++;
            }
            else if (c == '9')
            {
                if (oneCnt > 0)
                {
                    ans++;
                    oneCnt--;
                }
            }
        }

        ans += oneCnt / 2;

        Console.WriteLine(ans);
    }

    public static void Main(string[] args)
    {
        new Program().Solve();
    }
}

class Scanner
{
    public Scanner()
    {
        _pos = 0;
        _line = new string[0];
    }

    const char Separator = ' ';
    private int _pos;
    private string[] _line;

    #region スペース区切りで取得

    public string Next()
    {
        if (_pos >= _line.Length)
        {
            _line = Console.ReadLine().Split(Separator);
            _pos = 0;
        }

        return _line[_pos++];
    }

    public int NextInt()
    {
        return int.Parse(Next());
    }

    public long NextLong()
    {
        return long.Parse(Next());
    }

    public double NextDouble()
    {
        return double.Parse(Next());
    }

    #endregion

    #region 型変換

    private int[] ToIntArray(string[] array)
    {
        var result = new int[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = int.Parse(array[i]);
        }

        return result;
    }

    private long[] ToLongArray(string[] array)
    {
        var result = new long[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = long.Parse(array[i]);
        }

        return result;
    }

    private double[] ToDoubleArray(string[] array)
    {
        var result = new double[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = double.Parse(array[i]);
        }

        return result;
    }

    #endregion

    #region 配列取得

    public string[] Array()
    {
        if (_pos >= _line.Length)
            _line = Console.ReadLine().Split(Separator);

        _pos = _line.Length;
        return _line;
    }

    public int[] IntArray()
    {
        return ToIntArray(Array());
    }

    public long[] LongArray()
    {
        return ToLongArray(Array());
    }

    public double[] DoubleArray()
    {
        return ToDoubleArray(Array());
    }

    #endregion
}
0