結果
| 問題 |
No.145 yukiover
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-08-21 19:17:03 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 253 ms / 5,000 ms |
| コード長 | 2,042 bytes |
| コンパイル時間 | 2,306 ms |
| コンパイル使用メモリ | 79,868 KB |
| 実行使用メモリ | 58,508 KB |
| 最終ジャッジ日時 | 2024-10-15 09:53:34 |
| 合計ジャッジ時間 | 7,883 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 20 |
ソースコード
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
String s = sc.next();
List<Character> sList = new ArrayList<>();
List<Character> yukiList = new ArrayList<>();
yukiList.add('y');
yukiList.add('u');
yukiList.add('k');
yukiList.add('i');
int yCountup = 0;
int yCount = 0;
int uCountup = 0;
int uCount = 0;
int kCountup = 0;
int kCount = 0;
int iCountup = 0;
int iCount = 0;
int eCount = 0;
for (int i = 0; i < n; i++) {
sList.add(s.charAt(i));
if (sList.get(i) > 'y') {
yCountup++;
} else if(sList.get(i) == 'y') {
yCount++;
} else if (sList.get(i) > 'u') {
uCountup++;
} else if(sList.get(i) == 'u') {
uCount++;
} else if (sList.get(i) > 'k') {
kCountup++;
} else if(sList.get(i) == 'k') {
kCount++;
} else if (sList.get(i) > 'i') {
iCountup++;
} else if(sList.get(i) == 'i') {
iCount++;
} else {
eCount++;
}
}
int luck = 0;
luck += yCountup;
for (int i = 1; i <= yCount; i++) {
if (uCountup-- > 0 ) {
luck++;
continue;
}
if (uCount > 0) {
if (kCountup > 0) {
uCount--;
kCountup--;
luck++;
continue;
}
if (kCount > 0) {
if (iCountup > 0) {
uCount--;
kCount--;
iCountup--;
luck++;
continue;
}
if (iCount > 0) {
if (eCount > 0) {
uCount--;
kCount--;
iCount--;
eCount--;
luck++;
continue;
}
if (iCount-1 > 0) {
uCount--;
kCount--;
iCount--;
iCount--;
luck++;
continue;
}
}
if (kCount-1 > 0) {
uCount--;
kCount--;
kCount--;
luck++;
continue;
}
}
if (uCount-1 > 0) {
uCount--;
uCount--;
luck++;
continue;
}
}
if (--yCount > 0) {
luck++;
}
}
System.out.println(luck);
}
}