結果
| 問題 | No.910 素数部分列 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-01-15 00:07:08 |
| 言語 | C# (.NET 10.0.201) |
| 結果 |
AC
|
| 実行時間 | 71 ms / 1,000 ms |
| + 880µs | |
| コード長 | 1,480 bytes |
| 記録 | |
| コンパイル時間 | 5,070 ms |
| コンパイル使用メモリ | 170,908 KB |
| 実行使用メモリ | 196,824 KB |
| 最終ジャッジ日時 | 2026-07-20 10:28:50 |
| 合計ジャッジ時間 | 9,589 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 50 |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.csproj を復元しました (92 ミリ秒)。 main -> /home/judge/data/code/bin/Release/net10.0/main.dll main -> /home/judge/data/code/bin/Release/net10.0/publish/
ソースコード
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);
}
}