結果
問題 | No.10 +か×か |
ユーザー | はまやんはまやん |
提出日時 | 2017-06-09 17:00:32 |
言語 | Kotlin (1.9.23) |
結果 |
TLE
|
実行時間 | - |
コード長 | 3,027 bytes |
コンパイル時間 | 16,102 ms |
コンパイル使用メモリ | 449,964 KB |
実行使用メモリ | 385,680 KB |
最終ジャッジ日時 | 2024-11-20 09:28:03 |
合計ジャッジ時間 | 36,461 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 489 ms
74,820 KB |
testcase_01 | AC | 468 ms
104,796 KB |
testcase_02 | AC | 472 ms
79,640 KB |
testcase_03 | TLE | - |
testcase_04 | AC | 790 ms
140,188 KB |
testcase_05 | AC | 730 ms
127,372 KB |
testcase_06 | TLE | - |
testcase_07 | AC | 1,462 ms
242,924 KB |
testcase_08 | AC | 795 ms
134,304 KB |
testcase_09 | AC | 650 ms
112,968 KB |
testcase_10 | AC | 511 ms
78,736 KB |
testcase_11 | AC | 508 ms
385,680 KB |
コンパイルメッセージ
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() } }