結果
| 問題 |
No.145 yukiover
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-02-06 00:17:34 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,889 bytes |
| コンパイル時間 | 514 ms |
| コンパイル使用メモリ | 56,028 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-06-23 09:02:09 |
| 合計ジャッジ時間 | 1,356 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 9 WA * 11 |
ソースコード
#include<iostream>
using namespace std;
const int INF = 1<<30;
string s;
void read() {
int n;
cin >> n >> s;
}
void work() {
int cnt[128] = {};
for (int i = 0; i < s.size(); ++i)
++cnt[(int)s[i]];
int ans = 0;
for (int i = 'y' + 1; i <= 'z'; ++i) {
int nUse = cnt[i];
ans += nUse;
cnt[i] -= nUse;
}
for (int i = 'u' + 1; i <= 'z'; ++i) {
int nUse = INF;
if (i == 'y') {
nUse = min(nUse, cnt[i] / 2);
}
else {
nUse = min(nUse, cnt[i]);
}
ans += nUse;
cnt[(int)'y'] -= nUse;
cnt[i] -= nUse;
}
for (int i = 'k' + 1; i <= 'z'; ++i) {
int nUse = INF;
if (i == 'y') {
nUse = min(nUse, cnt[i] / 2);
}
else {
nUse = min(nUse, cnt[i]);
}
if (i == 'u') {
nUse = min(nUse, cnt[i] / 2);
}
else {
nUse = min(nUse, cnt[i]);
}
ans += nUse;
cnt[(int)'y'] -= nUse;
cnt[(int)'u'] -= nUse;
cnt[i] -= nUse;
}
for (int i = 'i' + 1; i <= 'z'; ++i) {
int nUse = INF;
if (i == 'y') {
nUse = min(nUse, cnt[i] / 2);
}
else {
nUse = min(nUse, cnt[i]);
}
if (i == 'u') {
nUse = min(nUse, cnt[i] / 2);
}
else {
nUse = min(nUse, cnt[i]);
}
if (i == 'k') {
nUse = min(nUse, cnt[i] / 2);
}
else {
nUse = min(nUse, cnt[i]);
}
ans += nUse;
cnt[(int)'y'] -= nUse;
cnt[(int)'u'] -= nUse;
cnt[(int)'k'] -= nUse;
cnt[i] -= nUse;
}
cout << ans << endl;
}
int main() {
read();
work();
return 0;
}