[JAVA] ABC - 014 - A & B & C.

AtCoder ABC 014 A&B&C AtCoder - 014

A --Kensho-Senseis Süßigkeitenverteilung

	private void solveA() {
		int a = nextInt();
		int b = nextInt();
		int mod = a % b;
		out.println(mod == 0 ? 0 : b - mod);
	}

B-Gesamtpreis

――Welche Position von x ist Bit 1?

	private void solveB() {
		int n = nextInt();
		int x = nextInt();
		int[] wk = IntStream.range(0, n).map(i -> nextInt()).toArray();

		int sum = 0;
		int index = 0;
		while (x != 0) {
			if ((x & 1) == 1) {
				sum += wk[index];
			}
			x >>= 1;
			index++;
		}

		out.println(sum);
	}

C - AtColor

――Es ist einfach, wenn Sie die kumulierte Summe nehmen. .. .. Ich kann mir keine andere Lösung vorstellen

	private void solveC() {
		int n = nextInt();
		int[][] wk = Stream.generate(() -> new int[] { nextInt(), nextInt() }).limit(n).toArray(int[][]::new);

		int[] imos = new int[1000001];
		for (int i = 0; i < n; i++) {
			imos[wk[i][0]] += 1;
			if (wk[i][1] + 1 < imos.length) {
				imos[wk[i][1] + 1] -= 1;
			}
		}
		for (int i = 1; i < imos.length; i++) {
			imos[i] = imos[i] + imos[i - 1];
		}

		Arrays.sort(imos);
		out.println(imos[imos.length - 1]);
	}

Recommended Posts

ABC - 013-A & B & C.
ABC - 023 - A & B & C.
ABC - 036-A & B & C.
ABC - 010 - A & B & C.
ABC - 015 - A & B & C.
ABC - 128 - A & B & C.
ABC - 012-A & B & C.
ABC - 054 - A & B & C.
ABC - 017 - A & B & C.
ABC - 029 - A & B & C.
ABC - 022 - A & B & C.
ABC - 019 - A & B & C.
ABC - 020 - A & B & C.
ABC - 030 - A & B & C.
ABC - 127 - A & B & C.
ABC - 007 - A & B & C.
ABC - 132 - A & B & C.
ABC - 026 - A & B & C.
ABC - 014 - A & B & C.
ABC - 016 - A & B & C.
ABC - 011-A & B & C.
ABC - 031 - A & B & C.
ABC - 021 - A & B & C.
ABC - 025 - A & B & C.
ABC - 024 - A & B & C.
ABC - 027 - A & B & C.
ABC - 080 - A & B & C.
ABC - 129 - A & B & C & D.
ABC - 133 - A & B & C & D.
ABC - 122 - A & B & C & D.
ABC - 125 - A & B & C & D.
ABC - 130 - A & B & C & D.
ABC - 126 - A & B & C & D.
ABC - 131 - A & B & C & D & E.
diverta 2019 Programmierwettbewerb A & B & C & D.
AtCoder Anfängerwettbewerb 169 A, B, C mit Rubin
atcoder ABC113 C Problem
ABC093 C - Gleiche Ganzzahlen
atcoder ABC115 C Problem
Eine Person, die C ++ schreibt, hat versucht, Java zu schreiben
Machen Sie einen SOAP-Aufruf in C #
Rufen Sie C-Sprachfunktionen von Swift aus auf
NLP4J 100 Sprachverarbeitungsklopfen mit NLP4J # 34 "A B"