結果

問題 No.145 yukiover
ユーザー te-shte-sh
提出日時 2017-02-01 15:57:50
言語 D
(dmd 2.106.1)
結果
WA  
実行時間 -
コード長 1,112 bytes
コンパイル時間 755 ms
コンパイル使用メモリ 83,744 KB
実行使用メモリ 4,388 KB
最終ジャッジ日時 2023-09-03 01:15:07
合計ジャッジ時間 1,800 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,384 KB
testcase_01 WA -
testcase_02 AC 2 ms
4,384 KB
testcase_03 WA -
testcase_04 AC 1 ms
4,380 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 2 ms
4,384 KB
testcase_09 AC 1 ms
4,384 KB
testcase_10 WA -
testcase_11 AC 2 ms
4,380 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 2 ms
4,384 KB
testcase_16 AC 2 ms
4,384 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import std.algorithm, std.conv, std.range, std.stdio, std.string;

void main()
{
  auto n = readln.chomp.to!size_t;
  auto s = readln.chomp;

  // abcdefghijklmnopqrstuvwxyz
  // 01234567890123456789012345
  auto ca = 0, ci = 8, ck = 10, cu = 20, cy = 24, cz = 25;

  auto hi = new int[](26);
  foreach (c; s) ++hi[c - 'a'];

  auto r = 0;

  auto rz = hi[cz];
  hi[cz] -= rz;
  r += rz;

  auto ry = hi[cy];
  hi[cy] -= ry;

  foreach (c; cu+1..cz+1) {
    auto ry_ = min(ry, hi[c]);
    hi[c] -= ry_;
    ry -= ry_;
    r += ry_;
  }

  auto ryu = min(ry, hi[cu]);
  hi[cu] -= ryu;

  foreach (c; ck+1..cz+1) {
    auto ryu_ = min(ryu, hi[c]);
    hi[c] -= ryu_;
    ryu -= ryu_;
    r += ryu_;
  }

  auto ryuk = min(ryu, hi[ck]);
  hi[ck] -= ryuk;

  foreach (c; ci+1..cz+1) {
    auto ryuk_ = min(ryuk, hi[c]);
    hi[c] -= ryuk_;
    ryuk -= ryuk_;
    r += ryuk_;
  }

  auto ryuki = min(ryuk, hi[ci]);
  hi[ci] -= ryuki;

  foreach (c; ca..cz+1) {
    auto ryuki_ = min(ryuki, hi[c]);
    hi[c] -= ryuki_;
    ryuki -= ryuki_;
    r += ryuki_;
  }

  r += (ry + ryu + ryuk + ryuki) / 2;

  writeln(r);
}
0