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 5661c2a

Browse files
1
1 parent a6db4f9 commit 5661c2a

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

‎src/main/kotlin/p30xx/Problem3025.kt

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package p30xx
2+
3+
import util.expect
4+
5+
fun main() {
6+
class Solution {
7+
fun numberOfPairs(points: Array<IntArray>): Int {
8+
points.sortWith(compareBy<IntArray> { it[0] }.thenByDescending { it[1] })
9+
10+
var result = 0
11+
12+
for (i in points.indices) {
13+
val (x1, y1) = points[i]
14+
15+
var minY = Int.MIN_VALUE
16+
17+
for (j in i + 1 until points.size) {
18+
val (x2, y2) = points[j]
19+
20+
if (x2 >= x1 && y2 <= y1 && y2 > minY) {
21+
result++
22+
23+
minY = y2
24+
}
25+
}
26+
}
27+
28+
return result
29+
}
30+
}
31+
32+
expect {
33+
Solution().numberOfPairs(
34+
arrayOf()
35+
)
36+
}
37+
}

0 commit comments

Comments
(0)

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