Submission #134388


Source Code Expand

import java.util.Scanner

/**
 * Created by hama_du on 2014/02/26.
 */
object Main extends App {
  val INF = Integer.MAX_VALUE / 100


  val in = new Scanner(System.in)
  val R,G,B = in.nextInt
  var answer = Integer.MAX_VALUE
  for {
    g <- -300 to 300
  } {
    val Gcost = cost(0, G, g)
    val Rcost = (-600 to 300).map(r => {
      if (r+R-1 < g) {
        cost(-100, R, r)
      } else {
        INF
      }
    }).min
    val Bcost = (-300 to 600).map(b => {
      if (g+G-1 < b) {
        cost(100, B, b)
      } else {
        INF
      }
    }).min
    answer = answer min (Rcost + Gcost + Bcost)
  }
  println(answer)

  // cost of moving N marbiles at p to [l,l+N)
  def cost(p: Int, n: Int, l: Int): Int = {
    if (p != 0) {
      cost(0, n, l-p)
    } else {
      if (l <= 0 && 0 < l+n) {
        val L = -l
        val R = l+n-1
        (L * (L+1) / 2) + (R * (R+1) / 2)
      } else {
        val diff = Math.abs(l) min Math.abs(l+n-1)
        (n * (n - 1) / 2) + diff * n
      }
    }

  }
}

Submission Info

Submission Time
Task D - マーブル
User hamadu
Language Scala (2.9.1)
Score 100
Code Size 1065 Byte
Status AC
Exec Time 1374 ms
Memory 55580 KB

Compile Error

warning: there were 2 deprecation warnings; re-run with -deprecation for details
one warning found

Judge Result

Set Name sub1 sub2 All
Score / Max Score 10 / 10 30 / 30 60 / 60
Status
AC × 29
AC × 57
AC × 82
Set Name Test Cases
sub1 sample_01_ABC.txt, test_ABC_01.txt, test_ABC_02.txt, test_ABC_03.txt, test_ABC_04.txt, test_ABC_05.txt, test_ABC_06.txt, test_ABC_07.txt, test_ABC_08.txt, test_ABC_09.txt, test_ABC_10.txt, test_ABC_11.txt, test_ABC_12.txt, test_ABC_13.txt, test_ABC_14.txt, test_ABC_15.txt, test_ABC_16.txt, test_ABC_17.txt, test_ABC_18.txt, test_ABC_19.txt, test_ABC_20.txt, test_ABC_21.txt, test_ABC_22.txt, test_ABC_23.txt, test_ABC_24.txt, test_ABC_25.txt, test_ABC_26.txt, test_ABC_27.txt, test_ABC_28.txt
sub2 sample_01_ABC.txt, sample_02_BC.txt, test_ABC_01.txt, test_ABC_02.txt, test_ABC_03.txt, test_ABC_04.txt, test_ABC_05.txt, test_ABC_06.txt, test_ABC_07.txt, test_ABC_08.txt, test_ABC_09.txt, test_ABC_10.txt, test_ABC_11.txt, test_ABC_12.txt, test_ABC_13.txt, test_ABC_14.txt, test_ABC_15.txt, test_ABC_16.txt, test_ABC_17.txt, test_ABC_18.txt, test_ABC_19.txt, test_ABC_20.txt, test_ABC_21.txt, test_ABC_22.txt, test_ABC_23.txt, test_ABC_24.txt, test_ABC_25.txt, test_ABC_26.txt, test_ABC_27.txt, test_ABC_28.txt, test_BC_29.txt, test_BC_30.txt, test_BC_31.txt, test_BC_32.txt, test_BC_33.txt, test_BC_34.txt, test_BC_35.txt, test_BC_36.txt, test_BC_37.txt, test_BC_38.txt, test_BC_39.txt, test_BC_40.txt, test_BC_41.txt, test_BC_42.txt, test_BC_43.txt, test_BC_44.txt, test_BC_45.txt, test_BC_46.txt, test_BC_47.txt, test_BC_48.txt, test_BC_49.txt, test_BC_50.txt, test_BC_51.txt, test_BC_52.txt, test_BC_53.txt, test_BC_54.txt, test_BC_55.txt
All test_ABC_01.txt, test_ABC_02.txt, test_ABC_03.txt, test_ABC_04.txt, test_ABC_05.txt, test_ABC_06.txt, test_ABC_07.txt, test_ABC_08.txt, test_ABC_09.txt, test_ABC_10.txt, test_ABC_11.txt, test_ABC_12.txt, test_ABC_13.txt, test_ABC_14.txt, test_ABC_15.txt, test_ABC_16.txt, test_ABC_17.txt, test_ABC_18.txt, test_ABC_19.txt, test_ABC_20.txt, test_ABC_21.txt, test_ABC_22.txt, test_ABC_23.txt, test_ABC_24.txt, test_ABC_25.txt, test_ABC_26.txt, test_ABC_27.txt, test_ABC_28.txt, test_BC_29.txt, test_BC_30.txt, test_BC_31.txt, test_BC_32.txt, test_BC_33.txt, test_BC_34.txt, test_BC_35.txt, test_BC_36.txt, test_BC_37.txt, test_BC_38.txt, test_BC_39.txt, test_BC_40.txt, test_BC_41.txt, test_BC_42.txt, test_BC_43.txt, test_BC_44.txt, test_BC_45.txt, test_BC_46.txt, test_BC_47.txt, test_BC_48.txt, test_BC_49.txt, test_BC_50.txt, test_BC_51.txt, test_BC_52.txt, test_BC_53.txt, test_BC_54.txt, test_BC_55.txt, test_C_56.txt, test_C_57.txt, test_C_58.txt, test_C_59.txt, test_C_60.txt, test_C_61.txt, test_C_62.txt, test_C_63.txt, test_C_64.txt, test_C_65.txt, test_C_66.txt, test_C_67.txt, test_C_68.txt, test_C_69.txt, test_C_70.txt, test_C_71.txt, test_C_72.txt, test_C_73.txt, test_C_74.txt, test_C_75.txt, test_C_76.txt, test_C_77.txt, test_C_78.txt, test_C_79.txt, test_C_80.txt, test_C_81.txt, test_C_82.txt
Case Name Status Exec Time Memory
sample_01_ABC.txt AC 1257 ms 54976 KB
sample_02_BC.txt AC 1266 ms 54820 KB
sample_03_C.txt AC 1269 ms 54668 KB
test_ABC_01.txt AC 1254 ms 54996 KB
test_ABC_02.txt AC 1247 ms 54912 KB
test_ABC_03.txt AC 1239 ms 54736 KB
test_ABC_04.txt AC 1276 ms 55180 KB
test_ABC_05.txt AC 1255 ms 54924 KB
test_ABC_06.txt AC 1255 ms 54928 KB
test_ABC_07.txt AC 1258 ms 54936 KB
test_ABC_08.txt AC 1256 ms 54512 KB
test_ABC_09.txt AC 1260 ms 54312 KB
test_ABC_10.txt AC 1270 ms 54848 KB
test_ABC_11.txt AC 1287 ms 54688 KB
test_ABC_12.txt AC 1275 ms 54492 KB
test_ABC_13.txt AC 1259 ms 55052 KB
test_ABC_14.txt AC 1255 ms 54604 KB
test_ABC_15.txt AC 1274 ms 55020 KB
test_ABC_16.txt AC 1266 ms 54828 KB
test_ABC_17.txt AC 1260 ms 54508 KB
test_ABC_18.txt AC 1328 ms 54696 KB
test_ABC_19.txt AC 1301 ms 54824 KB
test_ABC_20.txt AC 1289 ms 55392 KB
test_ABC_21.txt AC 1306 ms 54460 KB
test_ABC_22.txt AC 1324 ms 54512 KB
test_ABC_23.txt AC 1343 ms 54792 KB
test_ABC_24.txt AC 1295 ms 54512 KB
test_ABC_25.txt AC 1305 ms 54708 KB
test_ABC_26.txt AC 1295 ms 54408 KB
test_ABC_27.txt AC 1285 ms 54684 KB
test_ABC_28.txt AC 1277 ms 54876 KB
test_BC_29.txt AC 1286 ms 54972 KB
test_BC_30.txt AC 1265 ms 54888 KB
test_BC_31.txt AC 1292 ms 54704 KB
test_BC_32.txt AC 1284 ms 54612 KB
test_BC_33.txt AC 1270 ms 54500 KB
test_BC_34.txt AC 1268 ms 54908 KB
test_BC_35.txt AC 1263 ms 54812 KB
test_BC_36.txt AC 1274 ms 54616 KB
test_BC_37.txt AC 1305 ms 55248 KB
test_BC_38.txt AC 1283 ms 54692 KB
test_BC_39.txt AC 1260 ms 54816 KB
test_BC_40.txt AC 1264 ms 54692 KB
test_BC_41.txt AC 1256 ms 54796 KB
test_BC_42.txt AC 1241 ms 55004 KB
test_BC_43.txt AC 1262 ms 54648 KB
test_BC_44.txt AC 1257 ms 54740 KB
test_BC_45.txt AC 1261 ms 54672 KB
test_BC_46.txt AC 1250 ms 54820 KB
test_BC_47.txt AC 1289 ms 54852 KB
test_BC_48.txt AC 1278 ms 54952 KB
test_BC_49.txt AC 1261 ms 54792 KB
test_BC_50.txt AC 1262 ms 54464 KB
test_BC_51.txt AC 1256 ms 54956 KB
test_BC_52.txt AC 1275 ms 54880 KB
test_BC_53.txt AC 1263 ms 54712 KB
test_BC_54.txt AC 1255 ms 55080 KB
test_BC_55.txt AC 1267 ms 54780 KB
test_C_56.txt AC 1277 ms 54948 KB
test_C_57.txt AC 1362 ms 54676 KB
test_C_58.txt AC 1258 ms 54680 KB
test_C_59.txt AC 1276 ms 54736 KB
test_C_60.txt AC 1288 ms 54888 KB
test_C_61.txt AC 1287 ms 54660 KB
test_C_62.txt AC 1326 ms 54864 KB
test_C_63.txt AC 1374 ms 54912 KB
test_C_64.txt AC 1303 ms 55044 KB
test_C_65.txt AC 1305 ms 54692 KB
test_C_66.txt AC 1317 ms 55580 KB
test_C_67.txt AC 1246 ms 55448 KB
test_C_68.txt AC 1260 ms 55180 KB
test_C_69.txt AC 1242 ms 55268 KB
test_C_70.txt AC 1255 ms 54808 KB
test_C_71.txt AC 1273 ms 54880 KB
test_C_72.txt AC 1247 ms 55088 KB
test_C_73.txt AC 1241 ms 55020 KB
test_C_74.txt AC 1248 ms 54872 KB
test_C_75.txt AC 1260 ms 54936 KB
test_C_76.txt AC 1281 ms 55424 KB
test_C_77.txt AC 1236 ms 55116 KB
test_C_78.txt AC 1233 ms 54480 KB
test_C_79.txt AC 1260 ms 55448 KB
test_C_80.txt AC 1259 ms 54716 KB
test_C_81.txt AC 1248 ms 54820 KB
test_C_82.txt AC 1223 ms 54644 KB