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

AtCoder ABC 017 A&B&C AtCoder - 017

A --Procon

	private void solveA() {
		int res = 0;
		for (int i = 0; i < 3; i++) {
			int point = nextInt();
			int ratio = nextInt();
			res += point * ratio / 10;
		}

		out.println(res);
	}

B - Choku

--Wenn 'ch''o''k''u' eingeschlossen ist, wird es kein Choku-Wort sein

	private void solveB() {
		String res = next().replaceAll("ch", "").replaceAll("o", "").replaceAll("k", "").replaceAll("u", "");

		out.println(res.length() == 0 ? "YES" : "NO");
	}

C - Hohe Punktzahl

Schleife (Teilpunkt 30 + 70 / TLE)

4 6 1 3 30 2 3 40 3 6 25 6 6 10

――Zum Beispiel: Wenn Sie sich entscheiden, kein Juwel zu nehmen, ist dies wie folgt

Juwel 1 Juwel 2 Juwel 3 Juwel 4 Juwel 5 Juwel 6
Ruinen 1 30 30 30
Ruinen 2 40 40 40 40
Ruinen 3 25 25
Ruinen 4 10 10 10 10 10
gesamt
(Maximaler Wert ohne Juwelen)
75 35 10 80 80 70

――Wenn dies der Fall ist, wird der letzte nicht berücksichtigt ――Jedoch hatte ich das Gefühl, dass der kumulative Summenanteil durch die Imos-Methode implementiert werden könnte, also habe ich eine andere Lösung ausprobiert.

	private void solveC2() {
		int n = nextInt();
		int m = nextInt();

		int[] l = new int[n];
		int[] r = new int[n];
		int[] s = new int[n];
		int[][] res = new int[m + 1][1];
		for (int i = 0; i < n; i++) {
			l[i] = nextInt();
			r[i] = nextInt();
			s[i] = nextInt();
			for (int j = 1; j <= m; j++) {
				if (j < l[i] || r[i] < j) {
					res[j][0] += s[i];
				}
			}
		}

		Arrays.sort(res, (x, y) -> -Integer.compare(x[0], y[0]));
		out.println(res[0][0]);
	}

Imos-Methode (101-Punkte-Lösungsmethode)

Der folgende Teil der obigen Lösung wurde korrigiert

			for (int j = 1; j <= m; j++) {
				if (j < l[i] || r[i] < j) {
					res[j][0] += s[i];
				}
			}
	private void solveC() {
		int n = nextInt();
		int m = nextInt();

		int[] l = new int[n];
		int[] r = new int[n];
		int[] s = new int[n];
		int[] res = new int[m];
		for (int i = 0; i < n; i++) {
			l[i] = nextInt() - 1;
			r[i] = nextInt() - 1;
			s[i] = nextInt();
			res[0] += s[i];
			res[l[i]] -= s[i];
			if (r[i] < m - 1) {
				res[r[i] + 1] += s[i];
			}
		}

		for (int i = 1; i < res.length; i++) {
			res[i] = res[i] + res[i - 1];
		}
		Arrays.sort(res);
		out.println(res[m - 1]);
	}

Recommended Posts

ABC - 023 - A & B & C.
ABC - 036-A & B & C.
ABC - 010 - 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 - 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.
ABC - 131 - A & B & C & D & E.
diverta 2019 Programmierwettbewerb A & B & C & D.
atcoder ABC113 C Problem
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"