結果

問題 No.2790 Athena 3
ユーザー 👑 箱星箱星
提出日時 2021-07-10 10:27:04
言語 Kotlin
(1.9.23)
結果
WA  
実行時間 -
コード長 1,483 bytes
コンパイル時間 10,231 ms
コンパイル使用メモリ 439,004 KB
実行使用メモリ 54,552 KB
最終ジャッジ日時 2024-06-22 00:35:54
合計ジャッジ時間 15,471 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 240 ms
54,272 KB
testcase_02 AC 248 ms
54,112 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 244 ms
54,176 KB
testcase_08 AC 244 ms
54,276 KB
testcase_09 WA -
testcase_10 AC 245 ms
54,188 KB
testcase_11 AC 243 ms
54,372 KB
testcase_12 AC 265 ms
54,172 KB
testcase_13 AC 264 ms
54,268 KB
testcase_14 WA -
testcase_15 AC 250 ms
54,264 KB
testcase_16 AC 276 ms
54,280 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
    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): Int {
    return findArea(x2 - x1, y2 - y1, x3 - x1, y3 - y1)
}

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

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