Movatterモバイル変換


[0]ホーム

URL:


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

Commit9d062d7

Browse files
authored
Create 1383-maximum-performance-of-a-team.kt
1 parent6924dd2 commit9d062d7

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
classSolution {
2+
funmaxPerformance(n:Int,speed:IntArray,efficiency:IntArray,k:Int):Int {
3+
val mod=1_000_000_000+7
4+
val eng= efficiency.zip(speed)
5+
.sortedWith(compareBy({-it.first }))
6+
7+
var res=0L
8+
var speed=0L
9+
val minHeap=PriorityQueue<Int>()
10+
for ((eff, spd)in eng) {
11+
if (minHeap.size== k)
12+
speed-= minHeap.poll()
13+
speed+= spd
14+
minHeap.add(spd)
15+
res= maxOf(res, speed* eff)
16+
}
17+
18+
return (res% mod).toInt()
19+
}
20+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp