Submission #187766


Source Code Expand

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

public class Main {
	MyScanner sc = new MyScanner();
	Scanner sc2 = new Scanner(System.in);
	boolean judge;
	boolean judge2;
	int[] ng;
	int input;

	void run() {
		int N = sc.nextInt();
		int input = N;
		judge = false;
		judge2 = true;
		ng = new int[3];
		for (int i = 0; i < 3; i++) {
			ng[i] = sc.nextInt();
		}
		dfs(N, 0);
		System.out.println(judge ? "YES" : "NO");
	}

	void dfs(int N, int cnt) {
		if (!judge2) {
			return;
		}
		if (cnt == 101 && N >= input) {
			judge2 = false;
			return;
		}
		for (int i = 0; i < 3; i++) {
			if (ng[i] == N) {
				return;
			}
		}
		if (N <= 0) {
			if (N == 0) {
				judge = true;
			}
			return;
		}
		for (int i = 3; i >= 0; i--) {
			dfs(N - i, cnt + 1);
		}
	}

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

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

	void debug2(int[][] 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();
		}
	}

	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());
		}

		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;
			}
		}
	}
}

Submission Info

Submission Time
Task C - 123引き算
User suigingin
Language Java (OpenJDK 1.7.0)
Score 100
Code Size 2012 Byte
Status AC
Exec Time 761 ms
Memory 23128 KB

Judge Result

Set Name All
Score / Max Score 100 / 100
Status
AC × 28
Set Name Test Cases
All test_143_142_141_140.txt, test_1_1_2_3.txt, test_1_2_3_4.txt, test_200_200_2_3.txt, test_231_77_78_80.txt, test_235_124_126_125.txt, test_253_45_47_48.txt, test_297_223_224_225.txt, test_297_294_292_290.txt, test_297_297_30_83.txt, test_297_3_43_72.txt, test_298_125_123_124.txt, test_298_293_295_291.txt, test_298_298_4_8.txt, test_298_36_72_98.txt, test_298_55_3_43.txt, test_298_92_91_295.txt, test_299_200_151_65.txt, test_299_240_35_154.txt, test_299_300_299_298.txt, test_299_33_242_151.txt, test_299_56_57_58.txt, test_299_66_132_198.txt, test_300_271_44_68.txt, test_300_299_298_296.txt, test_300_30_99_183.txt, test_300_4_5_6.txt, test_84_34_64_36.txt
Case Name Status Exec Time Memory
sample_01.txt AC 468 ms 22964 KB
sample_02.txt AC 598 ms 23088 KB
sample_03.txt AC 489 ms 22960 KB
test_143_142_141_140.txt AC 519 ms 22956 KB
test_1_1_2_3.txt AC 468 ms 23080 KB
test_1_2_3_4.txt AC 444 ms 22964 KB
test_200_200_2_3.txt AC 460 ms 23088 KB
test_231_77_78_80.txt AC 434 ms 23128 KB
test_235_124_126_125.txt AC 739 ms 23092 KB
test_253_45_47_48.txt AC 650 ms 23092 KB
test_297_223_224_225.txt AC 557 ms 23056 KB
test_297_294_292_290.txt AC 479 ms 23088 KB
test_297_297_30_83.txt AC 416 ms 23084 KB
test_297_3_43_72.txt AC 556 ms 23080 KB
test_298_125_123_124.txt AC 645 ms 22976 KB
test_298_293_295_291.txt AC 603 ms 22960 KB
test_298_298_4_8.txt AC 551 ms 22964 KB
test_298_36_72_98.txt AC 721 ms 22952 KB
test_298_55_3_43.txt AC 760 ms 22964 KB
test_298_92_91_295.txt AC 691 ms 22964 KB
test_299_200_151_65.txt AC 436 ms 23064 KB
test_299_240_35_154.txt AC 481 ms 22964 KB
test_299_300_299_298.txt AC 470 ms 22964 KB
test_299_33_242_151.txt AC 484 ms 23092 KB
test_299_56_57_58.txt AC 465 ms 23008 KB
test_299_66_132_198.txt AC 435 ms 23004 KB
test_300_271_44_68.txt AC 524 ms 23080 KB
test_300_299_298_296.txt AC 761 ms 22960 KB
test_300_30_99_183.txt AC 584 ms 23092 KB
test_300_4_5_6.txt AC 473 ms 23080 KB
test_84_34_64_36.txt AC 467 ms 22964 KB