結果

問題 No.113 宝探し
ユーザー marumaru
提出日時 2016-03-23 18:38:54
言語 Java21
(openjdk 21)
結果
AC  
実行時間 131 ms / 5,000 ms
コード長 1,049 bytes
コンパイル時間 3,691 ms
コンパイル使用メモリ 77,628 KB
実行使用メモリ 41,404 KB
最終ジャッジ日時 2024-04-28 07:38:33
合計ジャッジ時間 8,044 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 129 ms
41,320 KB
testcase_01 AC 111 ms
39,600 KB
testcase_02 AC 122 ms
39,964 KB
testcase_03 AC 125 ms
41,144 KB
testcase_04 AC 123 ms
41,172 KB
testcase_05 AC 124 ms
40,600 KB
testcase_06 AC 123 ms
40,624 KB
testcase_07 AC 115 ms
40,104 KB
testcase_08 AC 113 ms
39,836 KB
testcase_09 AC 127 ms
41,104 KB
testcase_10 AC 122 ms
40,652 KB
testcase_11 AC 123 ms
41,140 KB
testcase_12 AC 125 ms
41,404 KB
testcase_13 AC 123 ms
40,612 KB
testcase_14 AC 125 ms
40,844 KB
testcase_15 AC 127 ms
40,588 KB
testcase_16 AC 123 ms
40,788 KB
testcase_17 AC 123 ms
41,404 KB
testcase_18 AC 126 ms
41,184 KB
testcase_19 AC 131 ms
40,884 KB
testcase_20 AC 128 ms
40,612 KB
testcase_21 AC 129 ms
41,132 KB
testcase_22 AC 128 ms
40,876 KB
testcase_23 AC 124 ms
40,748 KB
testcase_24 AC 128 ms
41,252 KB
testcase_25 AC 128 ms
41,392 KB
testcase_26 AC 115 ms
40,252 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;
import java.util.HashMap;

public class yukicoder_113 {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		String str = stdIn.next();
		String[] array = new String[str.length()];
		
		HashMap<String, Integer> map = new HashMap<String, Integer>();
		map.put(str.substring(0, 1), 1);
		
		for (int i = 1; i < array.length; i++) {
			array[i] = str.substring(i, i + 1);
			
			if (map.containsKey(array[i])) {
				map.put(array[i], map.get(array[i]) + 1);
			} else {
				map.put(array[i], 1);
			}
		}
		
		int north = 0, east = 0, west = 0, south = 0;
		
		if (map.get("N") != null) {
			north = map.get("N") * 1;
		}
		
		if (map.get("E") != null) {
			east = map.get("E") * 1;
		}
		
		if (map.get("W") != null) {
			west = map.get("W") * (-1);
		}
		
		if (map.get("S") != null) {
			south = map.get("S") * (-1);
		}
		
		double height = Math.pow(Math.abs(north + south),2);
		double width = Math.pow(Math.abs(east + west),2);
		
		System.out.println(Math.sqrt(height + width));
	}
}
0