AtCoder ABC 024 A&B&C AtCoder - 024
2019/05/27 Correction du nom du problème Correction de l'écriture du code pour le problème C `ʻint [] [] generation part``
――Pour le moment, si vous avez droit à une réduction après avoir fait la somme, vous pouvez réduire
	private void solveA() {
		int[] first = IntStream.range(0, 4).map(i -> nextInt()).toArray();
		int[] second = IntStream.range(0, 2).map(i -> nextInt()).toArray();
		int child = second[0] * first[0];
		int adult = second[1] * first[1];
		int total = child + adult;
		int sum = Arrays.stream(second).sum();
		if (sum >= first[3]) {
			total -= (sum * first[2]);
		}
		out.println(total);
	}
--Je publierai le processus tel quel --Commentez la simplification
«Je ne peux pas obtenir une explication de la solution. .. ..
	private void solveB() {
		int numN = nextInt();
		int numT = nextInt();
		int[] wk = IntStream.range(0, numN).map(i -> nextInt()).toArray();
		long res = 0;
		long preTime = 0;
		for (int i = 0; i < wk.length; i++) {
			long openTime = 0;
			long currentTime = wk[i];
			if (i == 0) {
				preTime = currentTime;
				openTime = numT;
			} else {
				if (preTime + numT > currentTime) {
					openTime -= (preTime + numT) - currentTime;
					openTime += numT;
					preTime = currentTime;
				} else {
					preTime = currentTime;
					openTime = numT;
				}
			}
			//			if (i != 0 && wk[i - 1] + numT > currentTime) {
			//				openTime -= (wk[i - 1] + numT) - currentTime;
			//				openTime += numT;
			//			} else {
			//				openTime = numT;
			//			}
			res += openTime;
		}
		out.println(res);
	}
――Il vaut mieux toujours aller dans la ville où vous pouvez aller le plus ce jour-là ――Déterminez le jour où vous pouvez commencer (le tout premier jour dans la plage mobile) ―― Allez dans la ville où vous pouvez aller ce jour-là (que vous alliez dans une grande ville ou une petite ville dépend de la tribu) ――Le début du lendemain est la ville dans laquelle vous vous trouvez actuellement --Créez un modèle pour passer d'une ville avec un petit nombre à une ville avec un grand nombre et un modèle d'un grand nombre à un petit nombre.
	private void solveC() {
		int n = nextInt();
		int d = nextInt();
		int k = nextInt();
		int[][] aLR = Stream.generate(() -> new int[] { nextInt(), nextInt() }).limit(d).toArray(int[][]::new);
		//		int[][] aLR = IntStream.range(0, d).collect(() -> new int[d][2],
		//				(t, i) -> {
		//					t[i][0] = nextInt();
		//					t[i][1] = nextInt();
		//				}, (t, u) -> {
		//					Stream.concat(Arrays.stream(t), Arrays.stream(u));
		//				});
		int[][] aST = Stream.generate(() -> new int[] { nextInt(), nextInt() }).limit(k).toArray(int[][]::new);
		//		int[][] aST = IntStream.range(0, k).collect(() -> new int[k][2],
		//				(t, i) -> {
		//					t[i][0] = nextInt();
		//					t[i][1] = nextInt();
		//				}, (t, u) -> {
		//					Stream.concat(Arrays.stream(t), Arrays.stream(u));
		//				});
		for (int[] js : aST) {
			long day = getDay(aLR, js[0], js[1]);
			out.println(day);
		}
	}
	private long getDay(int[][] aLR, int start, int end) {
		int current = start;
		if (start < end) {
			for (int i = 0; i < aLR.length; i++) {
				if (aLR[i][0] <= current && current <= aLR[i][1]) {
					current = aLR[i][1];
				}
				if (current >= end) {
					return i + 1;
				}
			}
		} else {
			for (int i = 0; i < aLR.length; i++) {
				if (aLR[i][0] <= current && current <= aLR[i][1]) {
					current = aLR[i][0];
				}
				if (current <= end) {
					return i + 1;
				}
			}
		}
		return -1;
	}
        Recommended Posts