結果

問題 No.145 yukiover
ユーザー d2verbd2verb
提出日時 2015-10-04 12:27:29
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,995 bytes
コンパイル時間 1,790 ms
コンパイル使用メモリ 89,396 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-27 01:56:23
合計ジャッジ時間 2,382 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 WA -
testcase_06 AC 1 ms
4,376 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 1 ms
4,380 KB
testcase_10 WA -
testcase_11 AC 2 ms
4,376 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 2 ms
4,380 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <utility>
#include <memory>
#include <functional>
#include <deque>
#include <cctype>
#include <numeric>
#include <ctime>
#include <bitset>
#include <cctype>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>

using namespace std;

//define
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define dump(x)  cerr << #x << " = " << (x) << endl;

#define INF (INT_MAX/2)
#define PI (2*acos(0.0))
#define EPS (1e-8)

#define REP(i,a,b) for(int i=(a); i<(b);++i)
#define rep(i,n) REP(i,0,n)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;

int dx[8] = {0, 1, 0, -1, 1, -1, 1, -1};
int dy[8] = {1, 0, -1, 0, 1, -1, -1, 1};

int N, alpha[256];
string s;
string list[5] = {"a", "yuki", "yuk", "yu", "y"};

int rec(int n){
  if(n == 5) return 0;

  bool flag = true;
  
  int minc = INF;
  for(int i = 0; i < list[n].size(); i++){
    flag &= (alpha[list[n][i]] != 0);
    minc = min(minc, alpha[list[n][i]]);
  }
  
  int cnt = 0;
  if(flag){
    for(int i = 0; i < list[n].size(); i++) alpha[list[n][i]]--;
    for(char c = list[n][list[n].size()-1]; c > list[n-1][list[n-1].size()-1]; c--){
      if(minc == 0) break;
      int m = min(minc, alpha[c]);
      cnt += m;
      minc -= m;
      alpha[c] -= m;
    }
  }

  cnt += rec(n + 1);
  return cnt;
}

int solve(){
  list[0][0] = char(list[0][0] - 1);
  for(int i = 0; i < s.size(); i++) alpha[s[i]]++;
  int res = alpha['z'];
  res += rec(1);
  return res;
}

int main(void){
  ios_base::sync_with_stdio(0);
  cin >> N >> s;
  cout << solve() << endl;
  return 0; 
}
0