We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 1e1cc04 + 07301c0 commit 39b89f5Copy full SHA for 39b89f5
suyeun84/202510/PGM LV2 퍼즐 게임 챌린지.md
@@ -0,0 +1,24 @@
1
+```java
2
+class Solution {
3
+ public int solution(int[] diffs, int[] times, long limit) {
4
+ int answer = 0;
5
+ int start = 1;
6
+ int end = 300000;
7
+ while (start < end) {
8
+ int mid = (start + end) / 2;
9
+ long time = 0;
10
+ for (int i = 0; i < diffs.length; i++) {
11
+ if (diffs[i] <= mid) time += times[i];
12
+ else {
13
+ int wrong = diffs[i] - mid;
14
+ if (i == 0) time += (times[0] * wrong + times[i]);
15
+ else time += ((times[i]+times[i-1]) * wrong + times[i]);
16
+ }
17
18
+ if (time <= limit) end = mid;
19
+ else start = mid + 1;
20
21
+ return start;
22
23
+}
24
+```
0 commit comments