結果
| 問題 | No.145 yukiover |
| コンテスト | |
| ユーザー |
C
|
| 提出日時 | 2026-10-27 14:27:49 |
| 言語 | C++23(gcc16) (gcc 16.2.0 + boost 1.92.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 2 ms / 5,000 ms |
| + 233µs | |
| コード長 | 1,303 bytes |
| 記録 | |
| コンパイル時間 | 6,981 ms |
| コンパイル使用メモリ | 389,400 KB |
| 実行使用メモリ | 9,868 KB |
| 最終ジャッジ日時 | 2026-10-27 14:28:07 |
| 合計ジャッジ時間 | 9,598 ms |
|
ジャッジサーバーID (参考情報) |
judge5_0 / judge4_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 20 |
ソースコード
#include <bits/stdc++.h>
#include <atcoder/all>
#include <boost/polygon/point_data.hpp>
#include <boost/polygon/voronoi.hpp>
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(x) begin(x),end(x)
#define sz(x) (int)(x).size()
using namespace std;
using namespace atcoder;
using ll=long long;
using ld=long double;
using vll=vector<ll>;
using vvll=vector<vll>;
using vi=vector<int>;
using vvi=vector<vi>;
using pll=pair<ll,ll>;
using pi=pair<int,int>;
using mint=modint998244353;
// using mint=modint1000000007;
// using mint2=static_modint<2>;
// using BoostPoint=boost::polygon::point_data<int>;
// using Voronoi=boost::polygon::voronoi_diagram<double>;
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
int N;
string S;
cin>>N>>S;
vi cnt(26);
for(auto s:S)cnt[s-'a']++;
auto ok=[N](int k,vi cnt){
string target="yuki";
int alive=k,alive2=N;
for(auto c:target){
rrep(i,c-'a'+1,26){
int mn=min(alive,cnt[i]);
alive2-=mn;
alive-=mn;
cnt[i]-=mn;
}
if(alive>cnt[c-'a'])return false;
cnt[c-'a']-=alive;
alive2-=alive;
}
if(alive>alive2)return false;
else return true;
};
int lo=0,hi=N+1;
while(hi-lo>1){
int mid=(lo+hi)/2;
if(ok(mid,cnt))lo=mid;
else hi=mid;
}
cout<<lo<<'\n';
}
C