結果

問題 No.2790 Athena 3
ユーザー 👑 箱星箱星
提出日時 2020-12-12 22:00:51
言語 Kotlin
(1.9.23)
結果
AC  
実行時間 336 ms / 2,000 ms
コード長 1,494 bytes
コンパイル時間 17,313 ms
コンパイル使用メモリ 452,668 KB
実行使用メモリ 54,328 KB
最終ジャッジ日時 2024-06-22 00:35:26
合計ジャッジ時間 23,550 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 282 ms
54,176 KB
testcase_01 AC 286 ms
54,316 KB
testcase_02 AC 288 ms
54,288 KB
testcase_03 AC 301 ms
54,300 KB
testcase_04 AC 336 ms
54,256 KB
testcase_05 AC 290 ms
54,276 KB
testcase_06 AC 290 ms
54,288 KB
testcase_07 AC 292 ms
54,212 KB
testcase_08 AC 311 ms
54,296 KB
testcase_09 AC 287 ms
54,252 KB
testcase_10 AC 285 ms
54,328 KB
testcase_11 AC 286 ms
54,176 KB
testcase_12 AC 281 ms
54,312 KB
testcase_13 AC 282 ms
54,292 KB
testcase_14 AC 289 ms
54,188 KB
testcase_15 AC 290 ms
54,172 KB
testcase_16 AC 297 ms
54,268 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.PrintWriter
import java.util.*
import kotlin.math.*

fun PrintWriter.solve() {
    val x1 = nextInt()
    val y1 = nextInt()
    val x2 = nextInt()
    val y2 = nextInt()
    val x3 = nextInt()
    val y3 = nextInt()
    val dx = arrayOf(1, -1, 0, 0)
    val dy = arrayOf(0, 0, 1, -1)
    var max = 0.0
    for (i1 in 0 until 4) {
        for (i2 in 0 until 4) {
            for (i3 in 0 until 4) {
                val nx1 = x1 + dx[i1]
                val ny1 = y1 + dy[i1]
                val nx2 = x2 + dx[i2]
                val ny2 = y2 + dy[i2]
                val nx3 = x3 + dx[i3]
                val ny3 = y3 + dy[i3]
                val area = findArea(nx1, ny1, nx2, ny2, nx3, ny3)
                max = maxOf(max, area)
            }
        }
    }
    println(max)
}

fun findArea(x1: Int, y1: Int, x2: Int, y2: Int, x3: Int, y3: Int): Double {
    return findArea(x2 - x1, y2 - y1, x3 - x1, y3 - y1)
}

fun findArea(a: Int, b: Int, c: Int, d: Int): Double {
    return abs(a * d - b * c) / 2.0
}

fun main() {
    val writer = PrintWriter(System.out, false)
    writer.solve()
    writer.flush()
}

// region Scanner
private var st = StringTokenizer("")
private val br = System.`in`.bufferedReader()

fun next(): String {
    while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())
    return st.nextToken()
}

fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextLine() = br.readLine()
fun nextDouble() = next().toDouble()
// endregion
0