結果

問題 No.145 yukiover
ユーザー chocoruskchocorusk
提出日時 2019-07-07 17:31:09
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,650 bytes
コンパイル時間 921 ms
コンパイル使用メモリ 99,972 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-15 08:11:20
合計ジャッジ時間 2,153 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,816 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 1 ms
6,940 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 1 ms
6,940 KB
testcase_06 AC 1 ms
6,940 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 WA -
testcase_09 AC 1 ms
6,940 KB
testcase_10 AC 1 ms
6,940 KB
testcase_11 AC 4 ms
6,944 KB
testcase_12 AC 4 ms
6,944 KB
testcase_13 AC 4 ms
6,940 KB
testcase_14 AC 4 ms
6,940 KB
testcase_15 WA -
testcase_16 AC 4 ms
6,940 KB
testcase_17 AC 4 ms
6,940 KB
testcase_18 AC 3 ms
6,944 KB
testcase_19 AC 4 ms
6,944 KB
testcase_20 AC 3 ms
6,944 KB
testcase_21 WA -
testcase_22 AC 4 ms
6,944 KB
testcase_23 AC 4 ms
6,940 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[8]={};
    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[8];
        for(int i=0; i<8; i++) cnt1[i]=cnt[i];
        int mada=min(x, cnt1[0]);
        cnt1[0]-=min(mada, cnt1[0]);
        cnt1[1]+=cnt1[0];
        mada-=min(mada, cnt1[1]);
        mada=min(mada, cnt1[2]);
        cnt1[2]-=mada;
        cnt1[3]+=cnt1[2];
        mada-=min(mada, cnt1[3]);
        mada=min(mada, cnt1[4]);
        cnt1[4]-=mada;
        cnt1[5]+=cnt1[4];
        mada-=min(mada, cnt1[5]);
        mada=min(mada, cnt1[6]);
        cnt1[6]-=mada;
        cnt1[7]+=cnt1[6];
        mada-=min(mada, cnt1[7]);
        if(mada>0) x2=x;
        else x1=x;
    }
    ans+=x1;
    cout<<ans<<endl;
    return 0;
}
0