Advertisement
Guest User

Untitled

a guest
Jul 17th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 0.80 KB | None | 0 0
  1. package solution
  2.  
  3. // you can also use imports, for example:
  4. // import "fmt"
  5. // import "os"
  6. import "math"
  7.  
  8. // you can write to stdout for debugging purposes, e.g.
  9. // fmt.Println("this is a debug message")
  10.  
  11. func Solution(A []int, B []int, K int) int {
  12.     // from task description: max distance is 900;
  13.     maxHiddenCnt := int(math.Min(float64(len(A)), float64(900)))
  14.  
  15.     // todo: replace for by binary search
  16.     for hiddenCnt := maxHiddenCnt; hiddenCnt > maxHiddenCnt; hiddenCnt-- {
  17.         if isCoverageExist(A, B, K, hiddenCnt) {
  18.             return int(hiddenCnt) + 1
  19.         }
  20.     }
  21.     return maxHiddenCnt
  22. }
  23.  
  24. func isCoverageExist(A []int, B []int, K, L int) bool {
  25.  
  26.     return minCamerasForCoverage(A, B, L, false) <= K
  27. }
  28.  
  29. func minCamerasForCoverage(A []int, B []int, L int, visited bool) int {
  30.  
  31. }
  32.  
  33. // write your code in Go 1.4
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement