Deep_Dev

https://swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AV14jJh6ACYCFAYD 

 

SW Expert Academy

SW ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์—ญ๋Ÿ‰ ๊ฐ•ํ™”์— ๋„์›€์ด ๋˜๋Š” ๋‹ค์–‘ํ•œ ํ•™์Šต ์ปจํ…์ธ ๋ฅผ ํ™•์ธํ•˜์„ธ์š”!

swexpertacademy.com

 

 


์ž…๋ ฅ๋ฐ›์€ ๋ฌธ์ž์—ด๋“ค์˜ ์ข…๋ฅ˜ = 10์ข…๋ฅ˜ 

๊ฐ ๋ฌธ์ž์—ด๋งˆ๋‹ค ๋ช‡๋ฒˆ ์ž…๋ ฅ๋ฐ›์•˜๋Š”์ง€ ์นด์šดํŠธํ•  cnt ๋ฐฐ์—ด ์ƒ์„ฑ ( 0์œผ๋กœ ์ดˆ๊ธฐํ™” )

๊ฐ ๋ฌธ์ž์—ด์ด ๊ฐ๊ฐ ๋ช‡๋ฒˆ ๋“ฑ์žฅํ–ˆ๋Š”์ง€๋ฅผ ์„ธ์„œ, ZRO ๋ถ€ํ„ฐ NIN๊นŒ์ง€ ์ˆœ์„œ๋Œ€๋กœ cntํ–ˆ๋˜ ๋งŒํผ ์ถœ๋ ฅ ๋ฐ˜๋ณต

 

๊ทผ๋ฐ ๋‹ค ํ’€์–ด๋†“๊ณ  ์‚ฝ์งˆ์„ ํ•œ ์ด์œ ๊ฐ€, ์ž…๋ ฅ ์„ค๋ช…์„ ๋ณด๋ฉด

"๊ทธ ๋‹ค์Œ ์ค„์— #๊ธฐํ˜ธ์™€ ํ•จ๊ป˜ ํ…Œ์ŠคํŠธ ์ผ€์ด์Šค์˜ ๋ฒˆํ˜ธ๊ฐ€ ์ฃผ์–ด์ง€๊ณ " ์ด๊ฑฐ๋ณด๊ณ  print๋กœ ์ถœ๋ ฅํ•˜๋ผ๋Š”๊ฑด์ค„์•Œ์•˜๋Š”๋ฐ ์ž…๋ ฅ์œผ๋กœ ๋ฐ›๋Š”๊ฑฐ๋‹ˆ๊นŒ ์ฃผ์˜..

(๋นก์นจ)

 

 

import java.util.Scanner;
class Solution{
	public static void main(String args[]) throws Exception{
    	Scanner kb = new Scanner(System.in);
        int t = kb.nextInt();
        for (int test_case = 1; test_case <= t; test_case++) {
            String s=kb.next();
            int n = kb.nextInt(); // n = ์‹œํ–‰ ํšŸ์ˆ˜
            String[] arr = new String[n]; // ๋ฌธ์ž์—ด ๋‹ด์„ ๋ฐฐ์—ด
            for (int i = 0; i < n; i++) {
                arr[i] = kb.next();
            }
            
            String[] text = {"ZRO", "ONE", "TWO", "THR", "FOR", "FIV", "SIX", "SVN", "EGT", "NIN"}; // ๋Œ€์ž… ํ•  ๋ฌธ์ž์—ด
            int[] cnt = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; // index ๊ณต๊ฐ„
 
            for (int i = 0; i < n; i++) { // ์ž…๋ ฅ๋ฐ›์€ ํšŸ์ˆ˜ ๋ชจ๋‘ ๋ฐ˜๋ณต
                int j = 0;
                while (true) {
                    if (arr[i].equals(text[j])) {
                        cnt[j]++;
                        break;
                    } else
                        j++;
                }
            }
            System.out.println("#" + test_case);
            for(int i=0; i<cnt.length; i++){
                for(int j=cnt[i]; j>0; j--){
                    System.out.print(text[i]+" ");
                }
            }
            System.out.println();
        }
    }
}