[JAVA] ABC - 130 - A & B & C & D.

AtCoder ABC 130 A&B&C&D AtCoder - 130

E und F werden in Kürze aktualisiert

A - Rounding

	private void solveA() {
		int x = nextInt();
		int a = nextInt();

		out.println(x < a ? 0 : 10);
	}

B - Bounding

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

		int d = 0;
		//Achten Sie auf D1=Da es bei 0 springt, beginnt es bei 1
		int cnt = 1;

		for (int i = 0; i < wk.length; i++) {
			d = d + wk[i];
			if (d <= x) {
				cnt++;
			}
		}

		out.println(cnt);
	}

C - Rectangle Cutting

	private void solveC() {
		double w = nextInt();
		double h = nextInt();
		double x = nextInt();
		double y = nextInt();

		double res = (w * h) / 2;
		String ref = String.format("%.10f", res);
		int bF = 0;
		if (w == 2 * x && h == 2 * y) {
			bF = 1;
		}
		out.println(ref + " " + bF);
	}

D - Enough Array

	private void solveD() {
		int n = nextInt();
		long k = nextLong();
		//		int[] wk = IntStream.range(0, n).map(i -> nextInt()).toArray();
		long[] wk = new long[n];
		for (int i = 0; i < n; i++) {
			wk[i] = nextLong();
		}

		long res = 0;
		long total = 0;
		int right = 0;
		/*
		 *Es scheint schwierig zu sein, "Kombinationen zu zählen, die K überschreiten"
		 *Mit der Politik "Kombinationen, die K nicht überschreiten, von der Gesamtzahl der Kombinationen zu subtrahieren"
		 */
		for (int left = 0; left < n; left++) {
			//wk bis total[right]Wenn Sie richtig hinzufügen können++
			while (right < n && total + wk[right] < k) {
				total += wk[right];
				right++;
			}
			//rechts ist das Maximum, das die Bedingung erfüllt
			res += (right - left);

			if (right == left) {
				right++;
			} else {
				total -= wk[left];
			}

		}

		/*
		 *Gesamtzahl der Kombinationen, die k ignorieren
		 *Weil es eine Unterspalte ist, n* (n+1)
		 *Wenn Sie vergessen, zu lange zu wirken, wird es zu int und WA
		 */
		long totalCnt = (long) n * ((long) n + 1L) / 2L;
		out.println(totalCnt - res);
	}

Recommended Posts

ABC - 129 - A & B & C & D.
ABC - 122 - 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.
ABC - 013-A & B & C.
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 - 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 - 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.
diverta 2019 Programmierwettbewerb A & B & C & D.
AtCoder Anfängerwettbewerb 169 A, B, C mit Rubin
atcoder ABC113 C Problem
Atcoder ABC70 D 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
Was ist ein zweidimensionales Ruby-Array?
Konvertieren Sie das 2D-Array von Swift in das 2D-Array von C.