結果

問題 No.1041 直線大学
ユーザー face4face4
提出日時 2021-04-11 14:30:58
言語 Kotlin
(1.9.23)
結果
AC  
実行時間 346 ms / 2,000 ms
コード長 906 bytes
コンパイル時間 11,711 ms
コンパイル使用メモリ 440,936 KB
実行使用メモリ 55,436 KB
最終ジャッジ日時 2024-04-28 00:19:09
合計ジャッジ時間 24,644 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 267 ms
52,016 KB
testcase_01 AC 264 ms
51,692 KB
testcase_02 AC 264 ms
51,672 KB
testcase_03 AC 264 ms
51,700 KB
testcase_04 AC 267 ms
51,800 KB
testcase_05 AC 265 ms
51,804 KB
testcase_06 AC 270 ms
51,936 KB
testcase_07 AC 284 ms
52,020 KB
testcase_08 AC 289 ms
52,056 KB
testcase_09 AC 290 ms
52,224 KB
testcase_10 AC 334 ms
55,436 KB
testcase_11 AC 334 ms
55,204 KB
testcase_12 AC 344 ms
55,228 KB
testcase_13 AC 288 ms
52,280 KB
testcase_14 AC 333 ms
55,416 KB
testcase_15 AC 305 ms
52,884 KB
testcase_16 AC 332 ms
55,392 KB
testcase_17 AC 279 ms
51,824 KB
testcase_18 AC 310 ms
53,520 KB
testcase_19 AC 330 ms
55,364 KB
testcase_20 AC 268 ms
51,680 KB
testcase_21 AC 310 ms
53,908 KB
testcase_22 AC 266 ms
51,684 KB
testcase_23 AC 341 ms
55,200 KB
testcase_24 AC 334 ms
55,420 KB
testcase_25 AC 313 ms
54,344 KB
testcase_26 AC 284 ms
52,000 KB
testcase_27 AC 289 ms
52,672 KB
testcase_28 AC 280 ms
51,716 KB
testcase_29 AC 265 ms
51,652 KB
testcase_30 AC 260 ms
51,888 KB
testcase_31 AC 268 ms
51,716 KB
testcase_32 AC 269 ms
51,792 KB
testcase_33 AC 265 ms
51,676 KB
testcase_34 AC 267 ms
51,740 KB
testcase_35 AC 281 ms
51,672 KB
testcase_36 AC 266 ms
51,756 KB
testcase_37 AC 260 ms
51,680 KB
testcase_38 AC 346 ms
55,244 KB
testcase_39 AC 280 ms
52,520 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import kotlin.math.abs
import kotlin.math.max

fun gcd(a:Int, b:Int): Int{
    return if(b==0) a else gcd(b, a%b)
}

fun main(){
    val n = readLine()!!.toInt()
    val points = Array(n){readLine()!!.split(" ").map{it.toInt()}}
    val f: (Int, Int) -> Pair<Int,Int> = { i, j ->
        var dx = points[j][0]-points[i][0]
        var dy = points[j][1]-points[i][1]
        with(gcd(abs(dx), abs(dy))){
            dx /= this
            dy /= this
        }
        Pair(dx, dy)
    }
    var answer = 0
    for(i in 0 until n){
        for(j in i+1 until n){
            var tmp = 2
            val (dx, dy) = f(i, j)
            for(k in 0 until n){
                if(k == i || k == j)    continue
                val (ddx, ddy) = f(i, k)
                if(ddx==dx && ddy==dy || -ddx==-dx && -ddy==-dy)    tmp++
            }
            answer = max(answer, tmp)
        }
    }
    println(answer)
}
0