結果

問題 No.145 yukiover
ユーザー nebukuro09
提出日時 2017-05-12 15:44:54
言語 D
(dmd 2.109.1)
結果
WA  
実行時間 -
コード長 1,098 bytes
コンパイル時間 908 ms
コンパイル使用メモリ 113,652 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-06-12 19:13:25
合計ジャッジ時間 1,952 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 11 WA * 9
権限があれば一括ダウンロードができます

ソースコード

diff #

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;


void main() {
    auto N = readln.chomp.to!int;
    auto S = readln.chomp;
    auto C = new int[](500);
    foreach (i; 0..N) C[S[i]] += 1;

    // Z
    int ans = C['z'];

    // Y[VWX]
    int bet = 0;
    for (char c = 'v'; c <= 'x'; c++) bet += C[c];
    bet = min(C['y'], bet);
    ans += bet;
    C['y'] -= bet;
    
    // YU[LMNOPQRST]
    bet = 0;
    for (char c = 'l'; c <= 't'; c++) bet += C[c];
    bet = [C['y'], C['u'], bet].reduce!min;
    ans += bet;
    C['y'] -= bet;
    C['u'] -= bet;

    // YUKJ
    bet = [C['y'], C['u'], C['k'], C['j']].reduce!min;
    ans += bet;
    C['y'] -= bet;
    C['u'] -= bet;
    C['k'] -= bet;

    // YUKK
    bet = [C['y'], C['u'], C['k'] / 2].reduce!min;
    ans += bet;
    C['y'] -= bet;
    C['u'] -= bet;
    
    // YUU
    bet = [C['y'], C['u'] / 2].reduce!min;
    ans += bet;
    C['y'] -= bet;
    
    // YY
    ans += C['y'] / 2;

    ans.writeln;
}
0