結果
問題 | No.10 +か×か |
ユーザー | 👑 はまやんはまやん |
提出日時 | 2017-06-09 17:00:32 |
言語 | Kotlin (1.9.23) |
結果 |
TLE
|
実行時間 | - |
コード長 | 3,027 bytes |
コンパイル時間 | 15,203 ms |
コンパイル使用メモリ | 431,932 KB |
実行使用メモリ | 64,276 KB |
最終ジャッジ日時 | 2023-08-12 19:05:45 |
合計ジャッジ時間 | 23,933 ms |
ジャッジサーバーID (参考情報) |
judge8 / judge10 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 422 ms
64,120 KB |
testcase_01 | AC | 403 ms
64,080 KB |
testcase_02 | AC | 418 ms
64,276 KB |
testcase_03 | TLE | - |
testcase_04 | -- | - |
testcase_05 | -- | - |
testcase_06 | -- | - |
testcase_07 | -- | - |
testcase_08 | -- | - |
testcase_09 | -- | - |
testcase_10 | -- | - |
testcase_11 | -- | - |
コンパイルメッセージ
Main.kt:57:10: warning: parameter 'args' is never used fun main(args: Array<String>) { ^ Main.kt:58:9: warning: variable 'time' is never used var time = measureTimeMillis { ^ Main.kt:72:9: warning: identity equality for arguments of types Int and Int is deprecated if (lenbuf === -1) throw InputMismatchException() ^ Main.kt:95:21: warning: 'toByte(): Byte' is deprecated. Conversion of Char to Number is deprecated. Use Char.code property instead. if(b >= '0'.toByte() && b <= '9'.toByte() || b == '-'.toByte()) break ^ Main.kt:95:42: warning: 'toByte(): Byte' is deprecated. Conversion of Char to Number is deprecated. Use Char.code property instead. if(b >= '0'.toByte() && b <= '9'.toByte() || b == '-'.toByte()) break ^ Main.kt:95:63: warning: 'toByte(): Byte' is deprecated. Conversion of Char to Number is deprecated. Use Char.code property instead. if(b >= '0'.toByte() && b <= '9'.toByte() || b == '-'.toByte()) break ^ Main.kt:97:22: warning: 'toByte(): Byte' is deprecated. Conversion of Char to Number is deprecated. Use Char.code property instead. if (b == '-'.toByte()) { ^ Main.kt:99:13: warning: the value 'readByte()' assigned to 'var b: Byte defined in ni' is never used b = readByte() ^ Main.kt:104:22: warning: 'toByte(): Byte' is deprecated. Conversion of Char to Number is deprecated. Use Char.code property instead. if (b >= '0'.toByte() && b <= '9'.toByte()) { ^ Main.kt:104:43: warning: 'toByte(): Byte' is deprecated. Conversion of Char to Number is deprecated. Use Char.code property instead. if (b >= '0'.toByte() && b <= '9'.toByte()) { ^ Main.kt:105:39: warning: 'toByte(): Byte' is deprecated. Conversion of Char to Number is deprecated. Use Char.code prope
ソースコード
import java.io.* import java.util.InputMismatchException import java.io.IOException import javax.swing.text.MutableAttributeSet import kotlin.system.measureTimeMillis var out = PrintWriter(System.out) /*--------------------------------------------------------------------------------------------------- ∧_∧ ∧_∧ (´<_` ) Welcome to My Coding Space! ( ´_ゝ`) / ⌒i / \ | | / / ̄ ̄ ̄ ̄/ | __(__ニつ/ _/ .| .|____ \/____/ (u ⊃ ---------------------------------------------------------------------------------------------------*/ fun solve() { var N = ni() var TOTAL = ni() var A = na(N) var dp = Array(N + 1, { Array(101010, {0}).toMutableList() }) var pre = Array<MutableList<String>>(N + 1, { Array(101010, {""}).toMutableList() }) dp[0][A[0]] = 1 for(i in 0 until N - 1) for(j in 0..100000) if(0 < dp[i][j]) { var x = A[i + 1] // + if(j + x < 101010) { dp[i + 1][j + x] = 1 if(pre[i + 1][j + x].length == 0) pre[i + 1][j + x] = pre[i][j] + "+" else if(pre[i][j] + "+" > pre[i + 1][j + x]) pre[i + 1][j + x] = pre[i][j] + "+" } // * if(j.toLong() * x.toLong() < 101010L) { dp[i + 1][j * x] = 1 if(pre[i + 1][j * x].length == 0) pre[i + 1][j * x] = pre[i][j] + "*" else if(pre[i][j] + "*" > pre[i + 1][j * x]) pre[i + 1][j * x] = pre[i][j] + "*" } } out.println(pre[N - 1][TOTAL]) } //--------------------------------------------------------------------------------------------------- fun main(args: Array<String>) { var time = measureTimeMillis { solve() out.flush() } //println("$time ms") } //--------------------------------------------------------------------------------------------------- private var inbuf = ByteArray(1024) private var lenbuf = 0 var ptrbuf = 0 var `is` = System.`in` fun readByte(): Byte { if (lenbuf === -1) throw InputMismatchException() if (ptrbuf >= lenbuf) { ptrbuf = 0 try { lenbuf = `is`.read(inbuf) } catch (e: IOException) { throw InputMismatchException() } if (lenbuf <= 0) return -1 } return inbuf[ptrbuf++] } fun na(n: Int) = IntArray(n, {ni()}) fun ni(): Int { var num = 0 var b: Byte var minus = false while (true) { b = readByte() if(b < 0) break if(b >= '0'.toByte() && b <= '9'.toByte() || b == '-'.toByte()) break if (b == '-'.toByte()) { minus = true b = readByte() } } while (true) { if (b >= '0'.toByte() && b <= '9'.toByte()) { num = num * 10 + (b - '0'.toByte()) } else { return if (minus) -num else num } b = readByte() } }