Submission #156223


Source Code Expand

import java.util.Scanner

/**
 * Created by hama_du on 2014/04/05.
 */
object Main extends App {
  val in = new Scanner(System.in)
  val N,M = in.nextInt()
  val ans = solve(0)

  println(ans._1 + " " + ans._2 + " " + ans._3)

  def solve(l: Int): (Int, Int, Int) = {
    if (l > N) {
      return (-1, -1, -1)
    }
    val take = isValid(N, M, l)
    if (take._1 != -1) {
      return take
    }
    return solve(l+1)
  }

  def isValid(n: Int, m: Int, old: Int): (Int, Int, Int) = {
    val leftLeg = m - old * 3
    val leftMan = n - old
    if (leftLeg < 0 || leftMan < 0 || leftLeg % 2 == 1) {
      return (-1, -1, -1)
    } else {
      val leftLeg_div_2 = leftLeg / 2
      val child = leftLeg_div_2 - leftMan
      val adult = n - (old + child)
      if (child < 0 || adult < 0) {
        return (-1, -1, -1)
      }
      if (adult * 2 + old * 3 + child * 4 == m) {
        return (adult, old, child)
      }
      return (-1, -1, -1)
    }
  }
}

Submission Info

Submission Time
Task C - スフィンクスのなぞなぞ
User hamadu
Language Scala (2.9.1)
Score 100
Code Size 1000 Byte
Status AC
Exec Time 1307 ms
Memory 47080 KB

Judge Result

Set Name smallA smallB all
Score / Max Score 10 / 10 20 / 20 70 / 70
Status
AC × 38
AC × 65
AC × 118
Set Name Test Cases
smallA test_1-1_ABC.txt, test_1-500_ABC.txt, test_100-103_ABC.txt, test_100-199_ABC.txt, test_100-1_ABC.txt, test_100-200_ABC.txt, test_100-201_ABC.txt, test_100-229_ABC.txt, test_100-300_ABC.txt, test_100-301_ABC.txt, test_100-399_ABC.txt, test_100-400_ABC.txt, test_100-401_ABC.txt, test_100-431_ABC.txt, test_100-473_ABC.txt, test_100-500_ABC.txt, test_33-106_ABC.txt, test_33-131_ABC.txt, test_33-132_ABC.txt, test_33-133_ABC.txt, test_33-134_ABC.txt, test_33-146_ABC.txt, test_33-51_ABC.txt, test_33-65_ABC.txt, test_33-66_ABC.txt, test_33-67_ABC.txt, test_33-71_ABC.txt, test_92-183_ABC.txt, test_92-184_ABC.txt, test_92-185_ABC.txt, test_92-310_ABC.txt, test_92-34_ABC.txt, test_92-367_ABC.txt, test_92-368_ABC.txt, test_92-369_ABC.txt, test_92-391_ABC.txt, test_92-434_ABC.txt, test_92-459_ABC.txt
smallB test_1-1_ABC.txt, test_1-500_ABC.txt, test_1-7500_AB.txt, test_100-103_ABC.txt, test_100-199_ABC.txt, test_100-1_ABC.txt, test_100-200_ABC.txt, test_100-201_ABC.txt, test_100-229_ABC.txt, test_100-300_ABC.txt, test_100-301_ABC.txt, test_100-399_ABC.txt, test_100-400_ABC.txt, test_100-401_ABC.txt, test_100-431_ABC.txt, test_100-473_ABC.txt, test_100-500_ABC.txt, test_100-7500_AB.txt, test_1500-1_AB.txt, test_1500-2999_AB.txt, test_1500-3000_AB.txt, test_1500-3001_AB.txt, test_1500-4072_AB.txt, test_1500-477_AB.txt, test_1500-500_AB.txt, test_1500-5768_AB.txt, test_1500-5999_AB.txt, test_1500-6000_AB.txt, test_1500-6001_AB.txt, test_1500-6268_AB.txt, test_1500-7024_AB.txt, test_1500-7500_AB.txt, test_33-106_ABC.txt, test_33-131_ABC.txt, test_33-132_ABC.txt, test_33-133_ABC.txt, test_33-134_ABC.txt, test_33-146_ABC.txt, test_33-51_ABC.txt, test_33-65_ABC.txt, test_33-66_ABC.txt, test_33-67_ABC.txt, test_33-71_ABC.txt, test_578-114_AB.txt, test_578-1155_AB.txt, test_578-1156_AB.txt, test_578-1157_AB.txt, test_578-1984_AB.txt, test_578-2101_AB.txt, test_578-2230_AB.txt, test_578-2311_AB.txt, test_578-2312_AB.txt, test_578-2313_AB.txt, test_578-2728_AB.txt, test_92-183_ABC.txt, test_92-184_ABC.txt, test_92-185_ABC.txt, test_92-310_ABC.txt, test_92-34_ABC.txt, test_92-367_ABC.txt, test_92-368_ABC.txt, test_92-369_ABC.txt, test_92-391_ABC.txt, test_92-434_ABC.txt, test_92-459_ABC.txt
all test_1-1_ABC.txt, test_1-500000_A.txt, test_1-500_ABC.txt, test_1-7500_AB.txt, test_100-103_ABC.txt, test_100-199_ABC.txt, test_100-1_ABC.txt, test_100-200_ABC.txt, test_100-201_ABC.txt, test_100-229_ABC.txt, test_100-300_ABC.txt, test_100-301_ABC.txt, test_100-399_ABC.txt, test_100-400_ABC.txt, test_100-401_ABC.txt, test_100-431_ABC.txt, test_100-473_ABC.txt, test_100-500000_A.txt, test_100-500_ABC.txt, test_100-7500_AB.txt, test_100000-175737_A.txt, test_100000-199999_A.txt, test_100000-1_A.txt, test_100000-200000_A.txt, test_100000-200001_A.txt, test_100000-300000_A.txt, test_100000-300001_A.txt, test_100000-321428_A.txt, test_100000-383852_A.txt, test_100000-399999_A.txt, test_100000-400000_A.txt, test_100000-400001_A.txt, test_100000-461143_A.txt, test_100000-482033_A.txt, test_100000-500000_A.txt, test_100000-500_A.txt, test_100000-7500_A.txt, test_12376-24751_A.txt, test_12376-24752_A.txt, test_12376-24753_A.txt, test_12376-4187_A.txt, test_12376-46199_A.txt, test_12376-49503_A.txt, test_12376-49504_A.txt, test_12376-49505_A.txt, test_12376-53158_A.txt, test_12376-57785_A.txt, test_12376-60441_A.txt, test_1500-1_AB.txt, test_1500-2999_AB.txt, test_1500-3000_AB.txt, test_1500-3001_AB.txt, test_1500-4072_AB.txt, test_1500-477_AB.txt, test_1500-500000_A.txt, test_1500-500_AB.txt, test_1500-5768_AB.txt, test_1500-5999_AB.txt, test_1500-6000_AB.txt, test_1500-6001_AB.txt, test_1500-6268_AB.txt, test_1500-7024_AB.txt, test_1500-7500_AB.txt, test_1931-2546_A.txt, test_1931-3861_A.txt, test_1931-3862_A.txt, test_1931-3863_A.txt, test_1931-6721_A.txt, test_1931-7547_A.txt, test_1931-7723_A.txt, test_1931-7724_A.txt, test_1931-7725_A.txt, test_1931-8765_A.txt, test_1931-9463_A.txt, test_33-106_ABC.txt, test_33-131_ABC.txt, test_33-132_ABC.txt, test_33-133_ABC.txt, test_33-134_ABC.txt, test_33-146_ABC.txt, test_33-51_ABC.txt, test_33-65_ABC.txt, test_33-66_ABC.txt, test_33-67_ABC.txt, test_33-71_ABC.txt, test_578-114_AB.txt, test_578-1155_AB.txt, test_578-1156_AB.txt, test_578-1157_AB.txt, test_578-1984_AB.txt, test_578-2101_AB.txt, test_578-2230_AB.txt, test_578-2311_AB.txt, test_578-2312_AB.txt, test_578-2313_AB.txt, test_578-2728_AB.txt, test_84391-168781_A.txt, test_84391-168782_A.txt, test_84391-168783_A.txt, test_84391-263979_A.txt, test_84391-294799_A.txt, test_84391-337563_A.txt, test_84391-337564_A.txt, test_84391-337565_A.txt, test_84391-407535_A.txt, test_84391-420642_A.txt, test_84391-98907_A.txt, test_92-183_ABC.txt, test_92-184_ABC.txt, test_92-185_ABC.txt, test_92-310_ABC.txt, test_92-34_ABC.txt, test_92-367_ABC.txt, test_92-368_ABC.txt, test_92-369_ABC.txt, test_92-391_ABC.txt, test_92-434_ABC.txt, test_92-459_ABC.txt
Case Name Status Exec Time Memory
sample_01.txt AC 1242 ms 43056 KB
sample_02.txt AC 1135 ms 43012 KB
sample_03.txt AC 1128 ms 43020 KB
test_1-1_ABC.txt AC 1165 ms 43012 KB
test_1-500000_A.txt AC 1111 ms 43032 KB
test_1-500_ABC.txt AC 1099 ms 42952 KB
test_1-7500_AB.txt AC 1213 ms 42888 KB
test_100-103_ABC.txt AC 1129 ms 43064 KB
test_100-199_ABC.txt AC 1146 ms 42960 KB
test_100-1_ABC.txt AC 1127 ms 43044 KB
test_100-200_ABC.txt AC 1130 ms 43020 KB
test_100-201_ABC.txt AC 1142 ms 43064 KB
test_100-229_ABC.txt AC 1158 ms 43020 KB
test_100-300_ABC.txt AC 1115 ms 43016 KB
test_100-301_ABC.txt AC 1160 ms 43016 KB
test_100-399_ABC.txt AC 1162 ms 43012 KB
test_100-400_ABC.txt AC 1118 ms 42936 KB
test_100-401_ABC.txt AC 1114 ms 43080 KB
test_100-431_ABC.txt AC 1106 ms 43008 KB
test_100-473_ABC.txt AC 1097 ms 43020 KB
test_100-500000_A.txt AC 1103 ms 43016 KB
test_100-500_ABC.txt AC 1124 ms 43060 KB
test_100-7500_AB.txt AC 1139 ms 43064 KB
test_100000-175737_A.txt AC 1182 ms 46888 KB
test_100000-199999_A.txt AC 1178 ms 46736 KB
test_100000-1_A.txt AC 1228 ms 45672 KB
test_100000-200000_A.txt AC 1107 ms 42968 KB
test_100000-200001_A.txt AC 1125 ms 43012 KB
test_100000-300000_A.txt AC 1128 ms 42932 KB
test_100000-300001_A.txt AC 1132 ms 42952 KB
test_100000-321428_A.txt AC 1135 ms 42960 KB
test_100000-383852_A.txt AC 1100 ms 43060 KB
test_100000-399999_A.txt AC 1122 ms 43052 KB
test_100000-400000_A.txt AC 1118 ms 43016 KB
test_100000-400001_A.txt AC 1156 ms 45700 KB
test_100000-461143_A.txt AC 1162 ms 46820 KB
test_100000-482033_A.txt AC 1262 ms 46844 KB
test_100000-500000_A.txt AC 1179 ms 45752 KB
test_100000-500_A.txt AC 1250 ms 47080 KB
test_100000-7500_A.txt AC 1186 ms 46436 KB
test_12376-24751_A.txt AC 1129 ms 43604 KB
test_12376-24752_A.txt AC 1132 ms 42936 KB
test_12376-24753_A.txt AC 1138 ms 43064 KB
test_12376-4187_A.txt AC 1150 ms 43616 KB
test_12376-46199_A.txt AC 1160 ms 43012 KB
test_12376-49503_A.txt AC 1123 ms 43068 KB
test_12376-49504_A.txt AC 1132 ms 42936 KB
test_12376-49505_A.txt AC 1159 ms 43652 KB
test_12376-53158_A.txt AC 1139 ms 43512 KB
test_12376-57785_A.txt AC 1142 ms 43652 KB
test_12376-60441_A.txt AC 1133 ms 43660 KB
test_1500-1_AB.txt AC 1069 ms 43056 KB
test_1500-2999_AB.txt AC 1118 ms 43020 KB
test_1500-3000_AB.txt AC 1146 ms 43012 KB
test_1500-3001_AB.txt AC 1166 ms 43140 KB
test_1500-4072_AB.txt AC 1133 ms 42924 KB
test_1500-477_AB.txt AC 1126 ms 43160 KB
test_1500-500000_A.txt AC 1122 ms 43056 KB
test_1500-500_AB.txt AC 1179 ms 43068 KB
test_1500-5768_AB.txt AC 1126 ms 43012 KB
test_1500-5999_AB.txt AC 1121 ms 43020 KB
test_1500-6000_AB.txt AC 1125 ms 42984 KB
test_1500-6001_AB.txt AC 1140 ms 43116 KB
test_1500-6268_AB.txt AC 1135 ms 42888 KB
test_1500-7024_AB.txt AC 1134 ms 42948 KB
test_1500-7500_AB.txt AC 1134 ms 43068 KB
test_1931-2546_A.txt AC 1132 ms 43060 KB
test_1931-3861_A.txt AC 1125 ms 43020 KB
test_1931-3862_A.txt AC 1088 ms 43060 KB
test_1931-3863_A.txt AC 1129 ms 43020 KB
test_1931-6721_A.txt AC 1140 ms 43084 KB
test_1931-7547_A.txt AC 1115 ms 43016 KB
test_1931-7723_A.txt AC 1114 ms 42956 KB
test_1931-7724_A.txt AC 1138 ms 43048 KB
test_1931-7725_A.txt AC 1152 ms 43132 KB
test_1931-8765_A.txt AC 1148 ms 43004 KB
test_1931-9463_A.txt AC 1127 ms 42888 KB
test_33-106_ABC.txt AC 1166 ms 42956 KB
test_33-131_ABC.txt AC 1066 ms 42936 KB
test_33-132_ABC.txt AC 1148 ms 43012 KB
test_33-133_ABC.txt AC 1133 ms 43136 KB
test_33-134_ABC.txt AC 1307 ms 42980 KB
test_33-146_ABC.txt AC 1137 ms 42936 KB
test_33-51_ABC.txt AC 1147 ms 43020 KB
test_33-65_ABC.txt AC 1118 ms 42932 KB
test_33-66_ABC.txt AC 1152 ms 43024 KB
test_33-67_ABC.txt AC 1189 ms 43008 KB
test_33-71_ABC.txt AC 1152 ms 43052 KB
test_578-114_AB.txt AC 1136 ms 43108 KB
test_578-1155_AB.txt AC 1169 ms 43060 KB
test_578-1156_AB.txt AC 1139 ms 43092 KB
test_578-1157_AB.txt AC 1122 ms 43060 KB
test_578-1984_AB.txt AC 1101 ms 42964 KB
test_578-2101_AB.txt AC 1160 ms 43068 KB
test_578-2230_AB.txt AC 1139 ms 42960 KB
test_578-2311_AB.txt AC 1141 ms 42884 KB
test_578-2312_AB.txt AC 1156 ms 42924 KB
test_578-2313_AB.txt AC 1143 ms 43060 KB
test_578-2728_AB.txt AC 1173 ms 43008 KB
test_84391-168781_A.txt AC 1162 ms 46536 KB
test_84391-168782_A.txt AC 1145 ms 42932 KB
test_84391-168783_A.txt AC 1151 ms 43016 KB
test_84391-263979_A.txt AC 1130 ms 43060 KB
test_84391-294799_A.txt AC 1154 ms 43020 KB
test_84391-337563_A.txt AC 1130 ms 43044 KB
test_84391-337564_A.txt AC 1121 ms 43072 KB
test_84391-337565_A.txt AC 1171 ms 46212 KB
test_84391-407535_A.txt AC 1150 ms 45448 KB
test_84391-420642_A.txt AC 1231 ms 46212 KB
test_84391-98907_A.txt AC 1123 ms 46460 KB
test_92-183_ABC.txt AC 1076 ms 42944 KB
test_92-184_ABC.txt AC 1069 ms 43064 KB
test_92-185_ABC.txt AC 1066 ms 43012 KB
test_92-310_ABC.txt AC 1058 ms 43048 KB
test_92-34_ABC.txt AC 1056 ms 43112 KB
test_92-367_ABC.txt AC 1075 ms 43064 KB
test_92-368_ABC.txt AC 1066 ms 43020 KB
test_92-369_ABC.txt AC 1086 ms 43044 KB
test_92-391_ABC.txt AC 1065 ms 43084 KB
test_92-434_ABC.txt AC 1057 ms 43012 KB
test_92-459_ABC.txt AC 1064 ms 43012 KB