AtCoder ABC 130 A&B&C&D AtCoder - 130
E and F will be updated soon
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;
		//Be sure to D1=Since it bounces at 0, it starts from 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
--I misread it
--About dividing a rectangle into two parts with a straight line passing through (x, y)
--The straight line passing through (x, y) intersects the outer circumference of the rectangle at right angles. (The subject is not always a right angle)
--If it does not intersect at right angles to the outer circumference, it is possible to bisect the rectangle by drawing a straight line through the center of gravity of the rectangle (because it is a rectangle).
--Therefore, the maximum divided value is half the area of the original rectangle.
--When (x, y) is the center of gravity, you can draw multiple straight lines to divide
--Rather, if (x, y) is not the center of gravity, only one straight line can be drawn.
	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
--It will be easier if you can read the problem ――Rather than searching for "combinations that exceed K", "subtract combinations that do not exceed K from the total number of combinations" ――By doing this, you will be able to count by the scale method. ――I think there is a way to count "combinations that exceed K", but I couldn't think of it.
	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;
		/*
		 *It seems difficult to count "combinations that exceed K", so
		 *With the policy of "subtracting combinations that do not exceed K from the total number of combinations"
		 */
		for (int left = 0; left < n; left++) {
			//wk to total[right]If you can add right++
			while (right < n && total + wk[right] < k) {
				total += wk[right];
				right++;
			}
			//right is the maximum that satisfies the condition
			res += (right - left);
			if (right == left) {
				right++;
			} else {
				total -= wk[left];
			}
		}
		/*
		 *Total number of combinations ignoring k
		 *Since it is a subsequence, n* (n+1)
		 *If you forget to cast to long, it becomes int and WA
		 */
		long totalCnt = (long) n * ((long) n + 1L) / 2L;
		out.println(totalCnt - res);
	}
        Recommended Posts