結果
| 問題 |
No.145 yukiover
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-06-14 19:21:20 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 235 ms / 5,000 ms |
| コード長 | 1,846 bytes |
| コンパイル時間 | 2,168 ms |
| コンパイル使用メモリ | 79,008 KB |
| 実行使用メモリ | 56,776 KB |
| 最終ジャッジ日時 | 2024-06-30 14:27:40 |
| 合計ジャッジ時間 | 7,405 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 20 |
ソースコード
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
new Main().run();
}
String yuki = "yuki";
void run() {
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
String str = sc.next();
int abcdefgh = 0, i = 0, j = 0, k = 0, lmnopqrst = 0, u = 0, vwx = 0, y = 0, z = 0;
for (int t = 0; t < str.length(); ++t) {
if (str.charAt(t) - 'i' < 0)
++abcdefgh;
else if (str.charAt(t) == 'i') {
++i;
} else if (str.charAt(t) - 'j' == 0)
++j;
else if (str.charAt(t) - 'k' == 0)
++k;
else if (str.charAt(t) - 'l' >= 0 && str.charAt(t) - 't' <= 0)
++lmnopqrst;
else if (str.charAt(t) - 'u' == 0)
++u;
else if (str.charAt(t) - 'v' >= 0 && str.charAt(t) - 'x' <= 0)
++vwx;
else if (str.charAt(t) == 'y')
++y;
else if (str.charAt(t) == 'z')
++z;
else {
tr(str.charAt(t));
throw new AssertionError();
}
}
int ans = 0;
while (y > 0 && u > 0 && k > 0 && i > 0 && abcdefgh > 0) {
++ans;
--y;
--u;
--k;
--i;
--abcdefgh;
}
while (y > 0 && u > 0 && k > 0 && i >= 2) {
++ans;
--y;
--u;
--k;
i -= 2;
--abcdefgh;
}
while (y > 0 && u > 0 && k > 0 && j > 0) {
++ans;
--y;
--u;
--k;
--i;
--j;
}
while (y > 0 && u > 0 && k >= 2) {
++ans;
--y;
--u;
k -= 2;
}
while (y > 0 && u > 0 && lmnopqrst > 0) {
++ans;
--y;
--u;
--lmnopqrst;
}
while (y > 0 && u >= 2) {
++ans;
--y;
u -= 2;
}
while (y > 0 && vwx > 0) {
++ans;
--y;
--vwx;
}
while (y >= 2) {
++ans;
y -= 2;
}
while (z > 0) {
++ans;
--z;
}
System.out.println(ans);
}
void tr(Object... objects) {
System.out.println(Arrays.deepToString(objects));
}
}