結果

問題 No.145 yukiover
ユーザー face4face4
提出日時 2018-12-24 21:57:55
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 5 ms / 5,000 ms
コード長 798 bytes
コンパイル時間 1,091 ms
コンパイル使用メモリ 64,916 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-26 03:04:08
合計ジャッジ時間 2,409 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include<iostream>
using namespace std;

int main(){
    int n;
    string s;
    cin >> n >> s;
    
    int cnt[26] = {};
    for(char x : s) cnt[x-'a']++;

    int ans = cnt[25];
    while(cnt[24]){
        cnt[24]--;
        int i, j, k, l;
        for(i = 20; i < 26; i++)    if(cnt[i]) {cnt[i]--; break;}
        if(i == 26) break;
        if(i > 20) {ans++; continue;}
        for(j = 10; j < 26; j++)    if(cnt[j]) {cnt[j]--; break;}
        if(j == 26) break;
        if(j > 10) {ans++; continue;}
        for(k = 8; k < 26; k++)     if(cnt[k]) {cnt[k]--; break;}
        if(k == 26) break;
        if(k > 8)  {ans++; continue;}
        for(l = 0; l < 26; l++)     if(cnt[l]) {cnt[l]--; break;}
        if(l == 26) break;
        ans++;
    }

    cout << ans << endl;
    
    return 0;
}
0