AtCoder ABC 028 A&B&C AtCoder - 028
Subtly A-C is a series of simple times. .. ..
** 2019/05/03 postscript ** B problem code fix
	private void solveA() {
		int numN = nextInt();
		if (numN <= 59) {
			out.println("Bad");
		} else if (numN <= 89) {
			out.println("Good");
		} else if (numN <= 99) {
			out.println("Great");
		} else {
			out.println("Perfect");
		}
	}
** 2019/05/03 Code correction **
--I have to check Collectors
	private void solveB() {
		String wk = next();
		Map<String, Long> tmp = Arrays.stream(wk.split(""))
				.collect(Collectors.groupingBy(s -> s, Collectors.counting()));
		String[] ref = { "A", "B", "C", "D", "E", "F" };
		String res = Arrays.stream(ref).map(i -> tmp.getOrDefault(i, 0L)
				.toString()).collect(Collectors.joining(" "));
		/*
		 *This problem is trim because it will be WA if there is a blank at the end
		 */
		out.println(res.trim());
	}
--Try to add them all --Use set to avoid duplication --treeset because I want you to sort --Extract the third element from the end and output
	private void solveC2() {
		int[] wk = IntStream.range(0, 5).map(i -> nextInt()).toArray();
		Set<Integer> set = new TreeSet<Integer>();
		for (int i = 0; i < wk.length; i++) {
			for (int j = i + 1; j < wk.length; j++) {
				for (int k = j + 1; k < wk.length; k++) {
					set.add(wk[i] + wk[j] + wk[k]);
				}
			}
		}
		List<Integer> list = new ArrayList<Integer>(set);
		out.println(list.get(list.size() - 3));
	}
-Explanation from P.9 of editorial
-If $ a <b <c <d <e $
--The maximum value is
- 
	private void solveC() {
		int[] wk = IntStream.range(0, 5).map(i -> nextInt()).toArray();
		int res = Integer.max(wk[4] + wk[3]+ wk[0], wk[4] + wk[2]+ wk[1]);
		out.println(res);
	}
        Recommended Posts