結果

問題 No.145 yukiover
ユーザー chocoruskchocorusk
提出日時 2019-07-07 17:45:44
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 5 ms / 5,000 ms
コード長 1,453 bytes
コンパイル時間 1,069 ms
コンパイル使用メモリ 99,088 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-15 08:30:50
合計ジャッジ時間 2,007 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
int n;
string s;
int c[26];
int main()
{
    cin>>n;
    cin>>s;
    for(int i=0; i<n; i++) c[s[i]-'a']++;
    int ans=c[25];
    int cnt[9]={};
    for(int i=0; i<25; i++){
        if(i==24) cnt[0]=c[i];
        else if(i>'u'-'a') cnt[1]+=c[i];
        else if(i=='u'-'a') cnt[2]=c[i];
        else if(i>'k'-'a') cnt[3]+=c[i];
        else if(i=='k'-'a') cnt[4]=c[i];
        else if(i>'i'-'a') cnt[5]+=c[i];
        else if(i=='i'-'a') cnt[6]=c[i];
        else cnt[7]+=c[i];
    }
    int x1=0, x2=cnt[0]+1;
    while(x2-x1>1){
        int x=(x1+x2)/2;
        int cnt1[9];
        for(int i=0; i<9; i++) cnt1[i]=cnt[i];
        int mada=x;
        bool dame=0;
        for(int i=0; i<4; i++){
            cnt1[2*i]-=mada;
            cnt1[2*i+1]+=cnt1[2*i];
            mada-=min(mada, cnt1[2*i+1]);
            if(mada>cnt1[2*i+2]){
                dame=1;
                break;
            }
        }
        if(dame) x2=x;
        else x1=x;
    }
    ans+=x1;
    cout<<ans<<endl;
    return 0;
}
0