AtCoder Beginner Contest 001

Submission #410219

Source codeソースコード

import java.util.Arrays;
import java.util.Scanner;

public class Main {
	MyScanner sc = new MyScanner();
	Scanner sc2 = new Scanner(System.in);
	long start = System.currentTimeMillis();
	long fin = System.currentTimeMillis();
	final int MOD = 1000000000;
	int[] dx = { 1, 0, 0, -1 };
	int[] dy = { 0, 1, -1, 0 };

	void run() {
		double deg = sc.nextDouble() / 10;
		double dis = sc.nextDouble() / 60;
		String Dir = "N";
		int W = 0;
		if (deg < 11.25) {

		} else if (deg < 33.75) {
			Dir = "NNE";
		} else if (deg < 56.25) {
			Dir = "NE";
		} else if (deg < 78.75) {
			Dir = "ENE";
		} else if (deg < 101.25) {
			Dir = "E";
		} else if (deg < 123.75) {
			Dir = "ESE";
		} else if (deg < 146.25) {
			Dir = "SE";
		} else if (deg < 168.75) {
			Dir = "SSE";
		} else if (deg < 191.25) {
			Dir = "S";
		} else if (deg < 213.75) {
			Dir = "SSW";
		} else if (deg < 236.25) {
			Dir = "SW";
		} else if (deg < 258.75) {
			Dir = "WSW";
		} else if (deg < 281.25) {
			Dir = "W";
		} else if (deg < 303.75) {
			Dir = "WNW";
		} else if (deg < 326.25) {
			Dir = "NW";
		} else if (deg < 348.75) {
			Dir = "NNW";
		}

		int tmp = (int) Math.round(dis * 10);
		if (tmp <= 2) {
			W = 0;
		} else if (tmp <= 15) {
			W = 1;
		} else if (tmp <= 33) {
			W = 2;
		} else if (tmp <= 54) {
			W = 3;
		} else if (tmp <= 79) {
			W = 4;
		} else if (tmp <= 107) {
			W = 5;
		} else if (tmp <= 138) {
			W = 6;
		} else if (tmp <= 171) {
			W = 7;
		} else if (tmp <= 207) {
			W = 8;
		} else if (tmp <= 244) {
			W = 9;
		} else if (tmp <= 284) {
			W = 10;
		} else if (tmp <= 326) {
			W = 11;
		} else {
			W = 12;
		}

		System.out.println((W == 0 ? 'C' : Dir) + " " + W);
	}

	public static void main(String[] args) {
		new Main().run();
	}

	void debug(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}

	void debug2(char[][] array) {
		for (int i = 0; i < array.length; i++) {
			for (int j = 0; j < array[i].length; j++) {
				System.out.print(array[i][j]);
			}
			System.out.println();
		}
	}

	boolean inner(int h, int w, int limH, int limW) {
		return 0 <= h && h < limH && 0 <= w && w < limW;
	}

	void swap(int[] x, int a, int b) {
		int tmp = x[a];
		x[a] = x[b];
		x[b] = tmp;
	}

	// find minimum i (a[i] >= border)
	int lower_bound(int a[], int border) {
		int l = -1;
		int r = a.length;
		while (r - l > 1) {
			int mid = (l + r) / 2;
			if (border <= a[mid]) {
				r = mid;
			} else {
				l = mid;
			}
		}
		// r = l + 1
		return r;
	}

	boolean palindrome(String s) {
		for (int i = 0; i < s.length() / 2; i++) {
			if (s.charAt(i) != s.charAt(s.length() - 1 - i)) {
				return false;
			}
		}
		return true;
	}

	class MyScanner {
		int nextInt() {
			try {
				int c = System.in.read();
				while (c != '-' && (c < '0' || '9' < c))
					c = System.in.read();
				if (c == '-')
					return -nextInt();
				int res = 0;
				do {
					res *= 10;
					res += c - '0';
					c = System.in.read();
				} while ('0' <= c && c <= '9');
				return res;
			} catch (Exception e) {
				return -1;
			}
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		String next() {
			try {
				StringBuilder res = new StringBuilder("");
				int c = System.in.read();
				while (Character.isWhitespace(c))
					c = System.in.read();
				do {
					res.append((char) c);
				} while (!Character.isWhitespace(c = System.in.read()));
				return res.toString();
			} catch (Exception e) {
				return null;
			}
		}

		int[] nextIntArray(int n) {
			int[] in = new int[n];
			for (int i = 0; i < n; i++) {
				in[i] = nextInt();
			}
			return in;
		}

		int[][] nextInt2dArray(int n, int m) {
			int[][] in = new int[n][m];
			for (int i = 0; i < n; i++) {
				in[i] = nextIntArray(m);
			}
			return in;
		}

		double[] nextDoubleArray(int n) {
			double[] in = new double[n];
			for (int i = 0; i < n; i++) {
				in[i] = nextDouble();
			}
			return in;
		}

		long[] nextLongArray(int n) {
			long[] in = new long[n];
			for (int i = 0; i < n; i++) {
				in[i] = nextLong();
			}
			return in;
		}

		char[][] nextCharField(int n, int m) {
			char[][] in = new char[n][m];
			for (int i = 0; i < n; i++) {
				String s = sc.next();
				for (int j = 0; j < m; j++) {
					in[i][j] = s.charAt(j);
				}
			}
			return in;
		}
	}
}

Submission

Task問題 C - 風力観測
User nameユーザ名 suigingin
Created time投稿日時
Language言語 Java (OpenJDK 1.7.0)
Status状態 AC
Score得点 100
Source lengthソースコード長 4545 Byte
File nameファイル名
Exec time実行時間 620 ms
Memory usageメモリ使用量 23460 KB

Test case

Set

Set name Score得点 / Max score Cases
all 100 / 100 00_sample_01.txt,00_sample_02.txt,00_sample_03.txt,00_sample_04.txt,00_sample_05.txt,00_sample_06.txt,00_sample_07.txt,00_sample_08.txt,test_01.txt,test_02.txt,test_03.txt,test_04.txt,test_05.txt,test_06.txt,test_07.txt,test_08.txt,test_09.txt,test_10.txt,test_11.txt,test_12.txt,test_13.txt,test_14.txt,test_15.txt,test_16.txt,test_17.txt,test_18.txt,test_19.txt,test_20.txt,test_21.txt,test_22.txt,test_23.txt,test_24.txt,test_25.txt,test_26.txt,test_27.txt,test_28.txt,test_29.txt,test_30.txt,test_31.txt,test_32.txt,test_33.txt,test_34.txt,test_35.txt,test_36.txt,test_37.txt,test_38.txt,test_39.txt,test_40.txt,test_41.txt,test_42.txt,test_43.txt,test_44.txt,test_45.txt,test_46.txt,test_47.txt,test_48.txt,test_49.txt,test_50.txt,test_51.txt,test_52.txt,test_53.txt,test_54.txt,test_55.txt,test_56.txt,test_57.txt,test_58.txt

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
00_sample_01.txt AC 427 ms 23396 KB
00_sample_02.txt AC 393 ms 23396 KB
00_sample_03.txt AC 390 ms 23400 KB
00_sample_04.txt AC 391 ms 23304 KB
00_sample_05.txt AC 397 ms 23392 KB
00_sample_06.txt AC 409 ms 23328 KB
00_sample_07.txt AC 399 ms 23316 KB
00_sample_08.txt AC 414 ms 23376 KB
test_01.txt AC 481 ms 23264 KB
test_02.txt AC 438 ms 23300 KB
test_03.txt AC 620 ms 23440 KB
test_04.txt AC 537 ms 23420 KB
test_05.txt AC 425 ms 23412 KB
test_06.txt AC 526 ms 23196 KB
test_07.txt AC 528 ms 23364 KB
test_08.txt AC 602 ms 23304 KB
test_09.txt AC 406 ms 23384 KB
test_10.txt AC 417 ms 23332 KB
test_11.txt AC 431 ms 23288 KB
test_12.txt AC 408 ms 23364 KB
test_13.txt AC 411 ms 23320 KB
test_14.txt AC 403 ms 23404 KB
test_15.txt AC 398 ms 23296 KB
test_16.txt AC 404 ms 23380 KB
test_17.txt AC 401 ms 23400 KB
test_18.txt AC 408 ms 23396 KB
test_19.txt AC 391 ms 23432 KB
test_20.txt AC 390 ms 23424 KB
test_21.txt AC 398 ms 23352 KB
test_22.txt AC 411 ms 23388 KB
test_23.txt AC 407 ms 23384 KB
test_24.txt AC 417 ms 23440 KB
test_25.txt AC 402 ms 23396 KB
test_26.txt AC 395 ms 23372 KB
test_27.txt AC 394 ms 23436 KB
test_28.txt AC 398 ms 23416 KB
test_29.txt AC 399 ms 23408 KB
test_30.txt AC 400 ms 23360 KB
test_31.txt AC 399 ms 23460 KB
test_32.txt AC 400 ms 23196 KB
test_33.txt AC 399 ms 23432 KB
test_34.txt AC 400 ms 23416 KB
test_35.txt AC 398 ms 23376 KB
test_36.txt AC 418 ms 23404 KB
test_37.txt AC 392 ms 23396 KB
test_38.txt AC 400 ms 23400 KB
test_39.txt AC 395 ms 23404 KB
test_40.txt AC 394 ms 23328 KB
test_41.txt AC 403 ms 23364 KB
test_42.txt AC 394 ms 23280 KB
test_43.txt AC 395 ms 23428 KB
test_44.txt AC 394 ms 23400 KB
test_45.txt AC 400 ms 23372 KB
test_46.txt AC 404 ms 23356 KB
test_47.txt AC 405 ms 23372 KB
test_48.txt AC 397 ms 23356 KB
test_49.txt AC 393 ms 23256 KB
test_50.txt AC 391 ms 23376 KB
test_51.txt AC 391 ms 23372 KB
test_52.txt AC 389 ms 23428 KB
test_53.txt AC 391 ms 23368 KB
test_54.txt AC 389 ms 23412 KB
test_55.txt AC 392 ms 23384 KB
test_56.txt AC 392 ms 23260 KB
test_57.txt AC 391 ms 23440 KB
test_58.txt AC 389 ms 23344 KB