結果

問題 No.1623 三角形の制作
ユーザー 👑 箱
提出日時 2021-07-23 22:21:10
言語 Kotlin
(1.9.10)
結果
AC  
実行時間 795 ms / 2,000 ms
コード長 1,228 bytes
コンパイル時間 16,231 ms
コンパイル使用メモリ 423,524 KB
実行使用メモリ 69,776 KB
最終ジャッジ日時 2023-09-25 22:28:25
合計ジャッジ時間 32,031 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 302 ms
50,436 KB
testcase_01 AC 302 ms
50,592 KB
testcase_02 AC 738 ms
65,088 KB
testcase_03 AC 721 ms
64,380 KB
testcase_04 AC 707 ms
65,460 KB
testcase_05 AC 700 ms
69,188 KB
testcase_06 AC 536 ms
56,404 KB
testcase_07 AC 707 ms
62,084 KB
testcase_08 AC 577 ms
56,484 KB
testcase_09 AC 701 ms
63,536 KB
testcase_10 AC 795 ms
69,776 KB
testcase_11 AC 762 ms
67,480 KB
testcase_12 AC 676 ms
60,236 KB
testcase_13 AC 699 ms
63,196 KB
testcase_14 AC 675 ms
60,852 KB
testcase_15 AC 698 ms
69,048 KB
testcase_16 AC 718 ms
69,180 KB
testcase_17 AC 710 ms
69,396 KB
testcase_18 AC 732 ms
69,068 KB
testcase_19 AC 658 ms
60,380 KB
testcase_20 AC 305 ms
50,456 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

fun PrintWriter.solve() {
    val n = nextInt()
    val r = Array(n) { nextInt() }
    val g = Array(n) { nextInt() }
    val b = Array(n) { nextInt() }
    val cnt = LongArray(6005) { 0 }
    for (v in r) {
        cnt[v]++
    }
    for (i in 0 until 6000) {
        cnt[i + 1] += cnt[i]
    }
    var ans = 0L
    val cnt_g = LongArray(3005) { 0 }
    val cnt_b = LongArray(3005) { 0 }
    for (v in g) {
        cnt_g[v]++
    }
    for (v in b) {
        cnt_b[v]++
    }
    for (i in 1 until 3002) {
        for (j in 1 until 3002) {
            ans += cnt[i + j - 1] * cnt_g[i] * cnt_b[j]
            ans -= cnt[max(i, j) - 1] * cnt_g[i] * cnt_b[j]
        }
    }
    println(ans)
}

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