Skip to content

Instantly share code, notes, and snippets.

@sungkmi
Created August 7, 2015 13:31
Show Gist options
  • Save sungkmi/f89f3792acc792697399 to your computer and use it in GitHub Desktop.
Save sungkmi/f89f3792acc792697399 to your computer and use it in GitHub Desktop.
object Fairland extends App {
def maxEmployee(n: Int, d: Int, sGen: (Int, Int, Int, Int), mGen: (Int, Int, Int, Int)): Int = {
val map = Map.empty[Int, Int] withDefaultValue 0
map(10)
val dx = Seq((18, 1), (18 + 395, -1)).groupBy(_._1).mapValues(_.map(_._2).sum).toSeq.sorted
((0, 0) /: dx) {
case ((current, max), (x, d)) =>
val next = current + d
(next, max max next)
}._2
}
}
import org.scalatest._
import Fairland._
class FairlandTest extends FunSuite {
test("sample #1") {
assert(maxEmployee(1, 395, (18, 246, 615815, 60), (73, 228, 14618, 195)) === 1)
}
test("sample #2") {
assert(maxEmployee(6, 5, (10, 1, 3, 17), (5, 2, 7, 19)) === 3)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment