結果

問題 No.145 yukiover
ユーザー ki_ki33ki_ki33
提出日時 2015-02-06 00:19:30
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 2,408 bytes
コンパイル時間 2,511 ms
コンパイル使用メモリ 80,756 KB
実行使用メモリ 59,208 KB
最終ジャッジ日時 2023-09-05 13:27:34
合計ジャッジ時間 25,559 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 126 ms
55,672 KB
testcase_01 AC 125 ms
55,944 KB
testcase_02 AC 124 ms
55,612 KB
testcase_03 WA -
testcase_04 AC 123 ms
55,740 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 123 ms
55,916 KB
testcase_09 AC 123 ms
56,448 KB
testcase_10 WA -
testcase_11 AC 206 ms
56,176 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 TLE -
testcase_16 AC 217 ms
56,672 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 273 ms
56,728 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedInputStream;
import java.io.IOException;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.*;
import java.util.Map.Entry;
import java.util.concurrent.ConcurrentSkipListSet;

public class Main {
	public static final int C =  1000000007;
	static final int CY = 1000000000;
	//static boolean MAP[][];
	static int K;
	static int N;
	static double P;
	static String S;
	static int M;
	static int MAX = -1;
	//static int tic[][];
	static int T[][];
	static int Y[];
	static double W[];
	//static int max;
	static long DP[];
	static int ST[][];
	//static int p[];
	//static ArrayList<HashSet<Integer>> al;
	static ConcurrentSkipListSet<Integer> TS;
	static ArrayList<Integer> AL;
	//static int a[][];
	//static char[][] ch;
	//static ArrayList<HashMap<Long, Long>> al;
	//static String a[];
	//static String str;

	public static void main(String[] args) {
		StringBuilder sb = new StringBuilder();
		BufferedInputStream bs = new BufferedInputStream(System.in);
		Scanner sc = new Scanner(bs);



		N = sc.nextInt();
		S =  sc.next();

		char c[] = S.toCharArray();
		
		Arrays.sort(c);

		long ans = 0;
		
		LOOP:for (int i=N-1; i >= 0; i--) {
			if (c[i] > 'y') {
				ans++;
			}else if (c[i] == 'y'){
				int indT = -1;
				for (int t=i-1; t >= 0; t--) {
					if (c[t] == 'y') {
						indT = t;
					}else if (c[t] > 'u'){
						indT = t;
						break;
					}else if (c[t] == 'u') {
						//TODO
						
						int indV = -1;
						for (int v=t-1; v >= 0; v--) {
							if (c[v] == 'u') {
								indV = v;
							}else if (c[v] > 'k'){
								indV = v;
								break;
							}else if (c[v] == 'k') {
								//TODO
								int indN = -1;
								for (int n=t-1; n >= 0; n--) {
									if (c[n] == 'u') {
										indN = n;
									}else if (c[n] > 'k'){
										indN = n;
										break;
									}else if (c[n] != 0){
										break;
									}
								}
								if (indN != -1) {
									c[indN] = 0;
									//ans++;
								}else {
									break LOOP;
								}
							}else if (c[v] != 0){
								break;
							}
						}
						if (indV != -1) {
							c[indV] = 0;
							//ans++;
						}else {
							break LOOP;
						}
					}else if (c[t] != 0){
						break ;
					}
				}
				if (indT != -1) {
					c[indT] = 0;
					ans++;
				}else {
					break LOOP;
				}
			}else if (c[i] != 0){
				break;
			}
		}

		
		
		System.out.println(ans);

	}


}
0