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

AtCoder ABC 031 A&B&C AtCoder - 031

Ein Problem


	private void solveA() {
		int a = nextInt();
		int d = nextInt();
		int res = 0;
		if (a > d) {
			res = a * (d + 1);
		} else {
			res = d * (a + 1);
		}

		out.println(res);
	}

B Problem

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

		for (int i : wk) {

			if (i < numL) {
				out.println(numL - i);
			} else if (numH < i) {
				out.println(-1);
			} else {
				out.println(0);
			}
		}

	}

C Problem

--Runden ――Es dauerte mehr als eine Stunde, um den Problemsatz aufgrund des Problems der Lesefähigkeit aussagekräftig zu machen, aber ... ――Ich habe es mit der folgenden Richtlinie implementiert. Ist es also in Ordnung?

  1. Bestimmen Sie zuerst die Position von Takahashi zwischen 0 und N.
  2. Entscheiden Sie mit der Position von Takahashi, wo Aoki den höchsten Punkt erreichen kann. 2-1. Aoki entscheidet den Ort zwischen 0-> N.
  3. Während Sie Aokis Auswahlposition von 0-> N verschieben, speichern Sie Takahashis Punkt, wenn Aokis Punkt maximiert ist.
  4. Die Antwort ist der maximale Takahashi-Punkt, wenn Sie [1-3] schleifen und Takahashis Position von 0-> N verschieben.

Ich bin nicht sicher, ob ich wieder die gleiche Antwort bekommen kann. .. ..

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

		int res = Integer.MIN_VALUE;

		/*
		 *Runden Sie ab, wo Takahashi wählt
		 *Aokis Hand wird abhängig von dem Ort entschieden, den Takahashi gewählt hat
		 *Sollte sein. .. ..
		 * i=Takahashis Auswahlort
		 */
		for (int i = 0; i < numN; i++) {
			/*
			 * Integer.MIN_Als ich es auf VALUE stellte, wurde der Wert auf die MAX-Seite geloopt, also ...
			 *Punkte von Takahashi und Aoki, wenn Takahashi diese Position wählt
			 */
			int aokiPoint = -1000000;
			int takahashiPoint = 0;

			/*
			 *Mit der ausgewählten Position von Takahashi behoben
			 *Finde einen Ort, an dem du Aoki wählen kannst
			 *An diesem Auswahlort ist Aokis Punkt maximal
			 * i==Wenn es j ist, kann es nicht ausgewählt werden, da es Takahashi und seine Hand bedeckt.
			 *Takahashis Punkt ist dort, wo Aokis Punkt der größte ist
			 *
			 */
			for (int j = 0; j < numN; j++) {
				if (i == j) {
					continue;
				}
				int innerAoki = -100000;
				int innerTakahashi = 0;
				/*
				 *Der kleinere beginnt an der ausgewählten Position von Aoki oder Takahashi
				 *Die größere Auswahlposition von Aoki oder Takahashi endet
				 *Da beide Enden enthalten sind, ist das Ende<=
				 */
				int cnt = 1;
				for (int k = Integer.min(i, j); k <= Integer.max(i, j); k++) {
					/*
					 *Seltsam ist Takahashis Punkt
					 *Auch ist Aokis Punkt
					 */
					if ((cnt & 1) == 1) {
						innerTakahashi += wk[k];
					} else {
						innerAoki += wk[k];
					}
					cnt++;
				}
				/*
				 *Aokis Punkt, wenn diese Position ausgewählt ist, ist
				 *Ob es bisher größer als Aokis Punkt ist
				 *Wenn es groß ist, wird Takahashis Punkt damit bestätigt
				 */
				if (innerAoki > aokiPoint) {
					//Wenn es größer als Aokis Punkt ist, ersetzen Sie es
					aokiPoint = innerAoki;
					//Aokis Punkte sind größer als zuvor, daher werden auch Takahashis Punkte ersetzt
					takahashiPoint = innerTakahashi;
				}
			}
			/*
			 *Ob diese Wahl von Takahashi größer ist als die vorherigen Punkte
			 */
			res = Integer.max(res, takahashiPoint);

		}

		out.println(res);
	}

Recommended Posts

ABC - 013-A & B & C.
ABC - 023 - A & B & C.
ABC - 036-A & B & C.
ABC - 028 - A & B & C.
ABC - 015 - A & B & C.
ABC - 128 - A & B & C.
ABC - 012-A & B & C.
ABC - 018 - 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 - 134 - A & B & C & D & E.
diverta 2019 Programmierwettbewerb A & B & C & D.
AtCoder Anfängerwettbewerb 169 A, B, C mit Rubin
ABC093 C - Gleiche Ganzzahlen
atcoder ABC115 C Problem
AtCoder Anfängerwettbewerb 170 A, B, C bis Rubin
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"