結果

問題 No.910 素数部分列
ユーザー iwkjoseciwkjosec
提出日時 2019-10-19 00:48:46
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 1,378 bytes
コンパイル時間 4,297 ms
コンパイル使用メモリ 101,788 KB
実行使用メモリ 27,296 KB
最終ジャッジ日時 2023-09-08 03:26:49
合計ジャッジ時間 9,173 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 54 ms
20,744 KB
testcase_01 AC 53 ms
20,624 KB
testcase_02 AC 52 ms
20,684 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 53 ms
20,656 KB
testcase_06 AC 53 ms
20,656 KB
testcase_07 AC 56 ms
20,664 KB
testcase_08 AC 55 ms
20,604 KB
testcase_09 AC 52 ms
20,652 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 56 ms
20,544 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 53 ms
18,596 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 55 ms
22,580 KB
testcase_20 WA -
testcase_21 WA -
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 AC 66 ms
27,296 KB
testcase_42 WA -
testcase_43 AC 66 ms
23,720 KB
testcase_44 AC 65 ms
23,328 KB
testcase_45 AC 65 ms
23,292 KB
testcase_46 WA -
testcase_47 WA -
testcase_48 AC 65 ms
24,592 KB
testcase_49 AC 68 ms
24,540 KB
testcase_50 AC 66 ms
24,504 KB
testcase_51 AC 59 ms
18,832 KB
testcase_52 AC 62 ms
24,676 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.Collections.Generic;
using System.Linq;
using System.Numerics;
using static System.Console;
using static System.Math;

class Program
{
    static void Main()
    {
        var N = int.Parse(ReadLine());
        var S = ReadLine();
        var ans = 0;
        var s = new List<int>();
        for (int i = 0; i < N; i++)
        {
            var n = S[i] - '0';
            if (n == 3 || n == 5 || n == 7) ans++;
            else s.Add(n);
        }

        var q = new List<int>();
        var c = 0;
        var m = 0;
        for (int i = 0; i < s.Count; i++)
        {
            if (s[i] == 1)
            {
                c++;
            }
            else
            {
                c--;
                m++;
            }
            if (c < 0)
            {
                q.Add(9);
                m--;
                c = 0;
            }
        }
        ans += m;
        for (int i = s.Count - 1; i >= 0; i--)
        {
            if (s[i] == 1) q.Add(1);
            else break;
        }
        var a = false;
        if (q.Count >= 3 && q[1] == 9 && q[q.Count - 1] == 1)
        {
            ans += 1;
            a = true;
        }

        var k = 0;
        for (int i = 0; i < q.Count; i++)
        {
            if (q[i] == 1) k++;
        }
        if (a) k--;
        ans += k / 2;
        WriteLine(ans);
    }
}
0