結果

問題 No.910 素数部分列
コンテスト
ユーザー kakel-san
提出日時 2026-01-15 00:07:08
言語 C#
(.NET 10.0.101)
結果
AC  
実行時間 79 ms / 1,000 ms
コード長 1,480 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 9,203 ms
コンパイル使用メモリ 168,628 KB
実行使用メモリ 196,332 KB
最終ジャッジ日時 2026-01-15 00:07:23
合計ジャッジ時間 14,779 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 50
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (107 ミリ秒)。
  main -> /home/judge/data/code/bin/Release/net10.0/main.dll
  main -> /home/judge/data/code/bin/Release/net10.0/publish/

ソースコード

diff #
raw source code

using System;
using static System.Console;
using System.Linq;
using System.Collections.Generic;
using System.Security.Cryptography;

class Program
{
    static int NN => int.Parse(ReadLine());
    static int[] NList => ReadLine().Split().Select(int.Parse).ToArray();
    static int[][] NArr(long n) => Enumerable.Repeat(0, (int)n).Select(_ => NList).ToArray();
    public static void Main()
    {
        Solve();
    }
    static void Solve()
    {
        var n = NN;
        var s = ReadLine();
        var list = new List<char>();
        var one = 0;
        var ans = 0;
        foreach (var c in s)
        {
            if (c == '3' || c == '5' || c == '7') ++ans;
            else list.Add(c);
            if (list.Count > 1 && list[^2] == '1' && list[^1] == '9')
            {
                ++ans;
                list.RemoveAt(list.Count - 1);
                list.RemoveAt(list.Count - 1);
            }
        }
        var nlist = new List<char>();
        foreach (var c in list)
        {
            nlist.Add(c);
            if (nlist.Count > 2 && nlist[^3] == '9' && nlist[^2] == '9' && nlist[^1] == '1')
            {
                ++ans;
                nlist.RemoveAt(nlist.Count - 1);
                nlist.RemoveAt(nlist.Count - 1);
                nlist.RemoveAt(nlist.Count - 1);
            }
        }
        foreach (var c in nlist) if (c == '1') ++one;
        WriteLine(ans + one / 2);
    }
}
0