結果
| 問題 |
No.145 yukiover
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-07-23 09:26:22 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 978 bytes |
| コンパイル時間 | 2,278 ms |
| コンパイル使用メモリ | 204,192 KB |
| 実行使用メモリ | 7,716 KB |
| 最終ジャッジ日時 | 2025-07-23 09:26:26 |
| 合計ジャッジ時間 | 3,023 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 4 |
| other | WA * 20 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int N; cin >> N;
string s; cin >> s;
sort(s.rbegin(),s.rend());
cout << s << endl;
vector<int> C(26);
for(auto c : s) C.at(c-'a')++;
string yuki = "yuki";
yuki += 'a'-1;
int answer = C.at(25);
C.at(25) = 0;
int low = 0,high = C.at(24)+1;
while(high-low > 1){
int mid = (high+low)/2;
auto D = C;
int left = mid; D.at(24) -= mid;
for(int c=1; c<5; c++){
int p1 = yuki.at(c-1)-'a',p2 = yuki.at(c)-'a';
for(int p=p2+1; p<=p1; p++){
left -= D.at(p);
if(left <= 0){left = 0; break;}
}
if(c == 4 || left > D.at(p2) || left <= 0) break;
D.at(p2) -= left;
}
if(left == 0) low = mid;
else high = mid;
}
answer += low;
cout << answer << endl;
}