結果
問題 |
No.145 yukiover
|
ユーザー |
👑 |
提出日時 | 2020-02-07 03:39:28 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 6 ms / 5,000 ms |
コード長 | 906 bytes |
コンパイル時間 | 517 ms |
コンパイル使用メモリ | 65,980 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-25 07:11:10 |
合計ジャッジ時間 | 1,430 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 20 |
ソースコード
#include <iostream> using namespace std; int dta[9];// z y x~v u t~l k j i h~a int main(){ char yuki[4] = {'y','u','k','i'}; int n;cin>>n; string s;cin>>s; for(int i = 0; s.size() > i; i++){ int ok = false; for(int j = 0; 8 > j; j+=2){ if(s[i] > yuki[j/2]){ ok = true; dta[j]++; break; }else if(s[i] == yuki[j/2]){ ok = true; dta[j+1]++; break; } } if(!ok){ dta[8]++; } } int tans = (dta[7]>dta[8]?dta[8]+(dta[7]-dta[8])/2:dta[7]); for(int i = 5; 0 <= i; i-=2){ int ans = min(dta[i],dta[i+1]); //cout << i << " " << i+1 << ":" << dta[i] << " " << dta[i+1] << endl; if(dta[i] > dta[i+1]){ dta[i] -= dta[i+1]; ans += min(dta[i],tans); if(dta[i] > tans){ dta[i]-= tans; ans += dta[i]/=2; } } tans = ans; } cout << tans + dta[0] << endl; }