結果

問題 No.145 yukiover
ユーザー h_nosonh_noson
提出日時 2016-06-08 22:48:28
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,662 bytes
コンパイル時間 731 ms
コンパイル使用メモリ 66,516 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-17 10:58:27
合計ジャッジ時間 1,684 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#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;
}
0