結果

問題 No.910 素数部分列
ユーザー mbanmban
提出日時 2019-10-18 21:46:11
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 3,017 bytes
コンパイル時間 4,965 ms
コンパイル使用メモリ 104,728 KB
実行使用メモリ 25,064 KB
最終ジャッジ日時 2023-09-07 21:50:20
合計ジャッジ時間 8,066 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 56 ms
20,664 KB
testcase_01 AC 57 ms
22,788 KB
testcase_02 AC 59 ms
20,656 KB
testcase_03 AC 57 ms
22,700 KB
testcase_04 AC 57 ms
20,844 KB
testcase_05 AC 57 ms
20,596 KB
testcase_06 AC 57 ms
20,748 KB
testcase_07 AC 57 ms
20,852 KB
testcase_08 AC 56 ms
18,812 KB
testcase_09 AC 57 ms
20,848 KB
testcase_10 AC 56 ms
20,876 KB
testcase_11 AC 57 ms
20,592 KB
testcase_12 AC 56 ms
20,656 KB
testcase_13 AC 57 ms
20,860 KB
testcase_14 AC 56 ms
22,864 KB
testcase_15 WA -
testcase_16 AC 56 ms
20,848 KB
testcase_17 AC 56 ms
20,684 KB
testcase_18 AC 56 ms
18,824 KB
testcase_19 AC 56 ms
20,732 KB
testcase_20 WA -
testcase_21 AC 57 ms
20,860 KB
testcase_22 AC 57 ms
20,828 KB
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 AC 63 ms
20,924 KB
testcase_42 WA -
testcase_43 AC 62 ms
21,132 KB
testcase_44 AC 62 ms
22,916 KB
testcase_45 AC 62 ms
20,856 KB
testcase_46 AC 62 ms
20,868 KB
testcase_47 WA -
testcase_48 AC 60 ms
20,924 KB
testcase_49 AC 61 ms
22,992 KB
testcase_50 AC 60 ms
20,940 KB
testcase_51 AC 62 ms
22,932 KB
testcase_52 AC 62 ms
20,884 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;
        int nineCnt = 0;
        foreach (var c in S)
        {
            if (c == '3' || c == '5' || c == '7')
            {
                ans++;
            }
            else if (c == '1')
            {
                if (nineCnt >= 2)
                {
                    nineCnt -= 2;
                    ans++;
                }
                else
                {
                    oneCnt++;
                }
            }
            else if (c == '9')
            {
                if (oneCnt >= 1)
                {
                    ans++;
                    oneCnt--;
                }
                else
                {
                    nineCnt++;
                }
            }
        }

        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