結果
問題 | No.145 yukiover |
ユーザー |
![]() |
提出日時 | 2015-02-05 16:53:48 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 4 ms / 5,000 ms |
コード長 | 520 bytes |
コンパイル時間 | 1,334 ms |
コンパイル使用メモリ | 159,448 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-23 08:28:41 |
合計ジャッジ時間 | 2,339 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 20 |
ソースコード
#include <bits/stdc++.h> using namespace std; int a[128]; // 'a' から c までの文字で作れる s より大きい文字列の個数 int count(string s, char c) { int res = 0; if (s.empty()) { for (; c >= 'a'; c--) res += a[c]; return res; } for (; c > s[0]; c--) res += a[c]; int k = min(a[c], count(s.substr(1), c - 1)); res += k + (a[c] - k) / 2; return res; } int main() { int N; cin >> N; string S; cin >> S; for (int i = 0; i < N; i++) a[S[i]]++; cout << count("yuki", 'z') << endl; }