結果
| 問題 |
No.145 yukiover
|
| コンテスト | |
| ユーザー |
h_noson
|
| 提出日時 | 2016-06-08 22:48:28 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,662 bytes |
| コンパイル時間 | 904 ms |
| コンパイル使用メモリ | 66,520 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-10-09 04:54:33 |
| 合計ジャッジ時間 | 2,143 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 WA * 2 |
| other | AC * 5 WA * 15 |
ソースコード
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;
#define REP(i,s,e) for (i = s; i <= e; i++)
#define rep(i,n) REP (i,0,(int)(n)-1)
#define RREP(i,s,e) for (i = s; i >= e; i--)
#define rrep(i,n) RREP (i,(int)(n)-1,0)
#define INF (int)1e8
#define MOD (int)(1e9+7)
typedef long long ll;
int main(void) {
int n;
string s;
cin >> n >> s;
int ans = 0;
int cnt[256] {}, sum[256];
for (auto c : s)
cnt[c]++;
ans += cnt['z'];
n -= cnt['z'];
cnt['z'] = 0;
sum['z'] = 0;
for (char c = 'y'; c >= 'a'; c--)
sum[c] = sum[c+1] + cnt[c];
int x = min({sum['y'],sum['v']/2,sum['a']/4});
ans += x;
cnt['y'] -= x;
int tmp = x * 2;
for (char c = 'a'; tmp > 0 && c <= 'y'; c++) {
int y = min(cnt[c],tmp);
tmp -= y;
cnt[c] -= y;
}
for (char c = 'v'; x > 0 && c <= 'y'; c++) {
int y = min(cnt[c],x);
x -= y;
cnt[c] -= y;
}
sum['z'] = 0;
for (char c = 'y'; c >= 'a'; c--)
sum[c] = sum[c+1] + cnt[c];
x = min({sum['y'],sum['u']/2,sum['l']/3,sum['a']/4});
ans += x;
cnt['y'] -= x;
cnt['u'] -= x;
tmp = x;
for (char c = 'a'; tmp > 0 && c <= 'y'; c++) {
int y = min(cnt[c],tmp);
tmp -= y;
cnt[c] -= y;
}
for (char c = 'l'; x > 0 && c <= 'y'; c++) {
int y = min(cnt[c],x);
x -= y;
cnt[c] -= y;
}
sum['z'] = 0;
for (char c = 'y'; c >= 'a'; c--)
sum[c] = sum[c+1] + cnt[c];
x = min({sum['y'],sum['u']/2,sum['k']/3,sum['j']/4});
ans += x;
cout << ans << endl;
return 0;
}
h_noson