結果

問題 No.145 yukiover
ユーザー kroton
提出日時 2015-02-12 05:59:32
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 6 ms / 5,000 ms
コード長 464 bytes
コンパイル時間 1,272 ms
コンパイル使用メモリ 159,360 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-06-23 19:02:41
合計ジャッジ時間 2,398 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
const string border = "yuki`";

int cnt[500];
bool gen(int idx){
	for(char c='a';c<='z';c++){
		if(c < border[idx])
			continue;

		if(cnt[c] == 0)
			continue;

		--cnt[c];
		if(c > border[idx] || gen(idx + 1))
			return true;

		++cnt[c];
	}
	return false;
}

int main(){
	int N; cin >> N;
	string S; cin >> S;
	
	for(char c : S)
		++cnt[c];

	int res = 0;
	while(gen(0))
		++res;

	cout << res << endl;
	return 0;
}
0