Created
August 7, 2015 13:31
-
-
Save sungkmi/f89f3792acc792697399 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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