結果
| 問題 | No.910 素数部分列 | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2019-10-18 21:45:48 | 
| 言語 | D (dmd 2.109.1) | 
| 結果 | 
                                WA
                                 
                             | 
| 実行時間 | - | 
| コード長 | 788 bytes | 
| コンパイル時間 | 716 ms | 
| コンパイル使用メモリ | 115,968 KB | 
| 実行使用メモリ | 6,948 KB | 
| 最終ジャッジ日時 | 2024-06-22 02:47:43 | 
| 合計ジャッジ時間 | 2,228 ms | 
| ジャッジサーバーID (参考情報) | judge4 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 25 WA * 25 | 
ソースコード
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.string;
void main() {
    auto N = readln.chomp.to!int;
    auto S = readln.chomp;
    auto T = S.filter!(s => s == '1' || s == '9').array;
    int ans = S.length.to!int - T.length.to!int;
    int ichi = 0;
    int kyuu = 0;
    foreach_reverse (i; 0..T.length.to!int) {
        if (T[i] == '1') {
            if (kyuu > 0) {
                ans += 1;
                kyuu -= 1;
            } else {
                ichi += 1;
            }
        } else {
            kyuu += 1;
        }
    }
    ans += ichi / 2;
    ichi %= 2;
    if (ichi > 0 && kyuu > 1) ans += 1;
    ans.writeln;
}
            
            
            
        