結果
問題 | No.145 yukiover |
ユーザー |
![]() |
提出日時 | 2015-02-28 01:04:12 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 6 ms / 5,000 ms |
コード長 | 1,618 bytes |
コンパイル時間 | 1,034 ms |
コンパイル使用メモリ | 104,220 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-23 22:40:40 |
合計ジャッジ時間 | 1,719 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 20 |
ソースコード
#define _USE_MATH_DEFINES #define _CRT_SECURE_NO_DEPRECATE #include <cstdio> #include <cstdlib> #include <cstring> #include <cmath> #include <climits> #include <cfloat> #include <ctime> #include <cassert> #include <map> #include <utility> #include <set> #include <iostream> #include <memory> #include <string> #include <vector> #include <algorithm> #include <functional> #include <sstream> #include <complex> #include <stack> #include <queue> #include <numeric> #include <list> #include <iomanip> #include <fstream> #include <iterator> #include <bitset> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair<int, int> Pii; typedef pair<ll, ll> Pll; #define FOR(i,n) for(int i = 0; i < (n); i++) #define sz(c) ((int)(c).size()) #define ten(x) ((int)1e##x) #define tenll(x) ((ll)1e##x) template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; } int main(){ const string base = "yuki"; int n; cin >> n; string s; cin >> s; vector<int> x(9); FOR(i, n){ int pt = 0; while (pt < 4 && s[i] < base[pt]) pt++; if (pt != 4 && s[i] == base[pt]) x[pt * 2 + 1]++; else x[pt * 2]++; } int ans = x[0]; int a, b, c, d, e, f, g, h; tie(a, b, c, d, e, f, g, h) = tie(x[1], x[2], x[3], x[4], x[5], x[6], x[7], x[8]); while (a&&c&&e&&g&&h) ans++, a--, c--, e--, g--, h--; while (a&&c&&e&&g/2) ans++, a--, c--, e--, g -= 2; while (a&&c&&e&&f) ans++, a--, c--, e--, f--; while (a&&c&&e/2) ans++, a--, c--, e -= 2; while (a&&c&&d) ans++, a--, c--, d--; while (a&&c/2) ans++, a--, c -= 2; while (a&&b) ans++, a--, b--; while (a/2) ans++, a-=2; cout << ans << endl; }