Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit c53e574

Browse files
1
1 parent d2ffadf commit c53e574

File tree

1 file changed

+2
-9
lines changed

1 file changed

+2
-9
lines changed

‎src/main/kotlin/p25xx/Problem2554.kt

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ import util.expect
55
fun main() {
66
class Solution {
77
fun maxCount(banned: IntArray, n: Int, maxSum: Int): Int {
8-
banned.sort()
9-
var banIndex = 0
8+
val bannedSet = banned.toMutableSet()
109

1110
var sum = 0L
1211
var result = 0
@@ -16,16 +15,10 @@ fun main() {
1615
break
1716
}
1817

19-
banIndex == banned.size ||num< banned[banIndex] -> {
18+
!bannedSet.remove(num) -> {
2019
sum += num
2120
result++
2221
}
23-
24-
else -> {
25-
while (banIndex < banned.size && num == banned[banIndex]) {
26-
banIndex++
27-
}
28-
}
2922
}
3023
}
3124

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /