本文整理汇总了Golang中codejam/ProblemReader.ProblemReader.NNums方法的典型用法代码示例。如果您正苦于以下问题:Golang ProblemReader.NNums方法的具体用法?Golang ProblemReader.NNums怎么用?Golang ProblemReader.NNums使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类codejam/ProblemReader.ProblemReader
的用法示例。
在下文中一共展示了ProblemReader.NNums方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: solver
func solver(in *ProblemReader.ProblemReader) string {
turnAround := in.Num()
nums := in.NNums(2)
nA, nB := nums[0], nums[1]
allTrips := make([]trip, nA+nB)
for _, v := range allStations {
v.clear()
}
for j := 0; j < nA; j++ {
allTrips[j] = readTrip(in, A, B)
}
for j := 0; j < nB; j++ {
allTrips[nA+j] = readTrip(in, B, A)
}
sort.Sort(tripArray(allTrips))
for _, t := range allTrips {
src, dst := allStations[t.src], allStations[t.dst]
// fmt.Printf("trip:%v, from %v to %v\n", t, src, dst)
src.getTrain(t.depart)
dst.addTrain(t.arrive + turnAround)
}
return fmt.Sprintf("%d %d", allStations[A].reserved, allStations[B].reserved)
}
示例2: solver
func solver(in *ProblemReader.ProblemReader) string {
credit := in.Num()
items := in.Num()
prices := in.NNums(items)
p0, p1 := pairSum(credit, prices)
return fmt.Sprintf("%d %d", p0+1, p1+1)
}
示例3: loadBoard
func loadBoard(in *ProblemReader.ProblemReader) *board {
hw := in.NNums(2)
b := new(board)
b.height, b.width = hw[0], hw[1]
b.cell = make([][]*Cell, b.height)
for j := 0; j < b.height; j++ {
b.cell[j] = make([]*Cell, b.width)
altitude := in.NNums(b.width)
for k := 0; k < b.width; k++ {
b.cell[j][k] = &Cell{altitude: altitude[k]}
}
}
return b
}
示例4: solver
func solver(in *ProblemReader.ProblemReader) string {
n := in.Num()
v1 := in.NNums(n)
v2 := in.NNums(n)
sort.SortInts(v1)
sort.SortInts(v2)
var sum int64 = 0
for j := 0; j < n; j++ {
sum += int64(v1[j]) * int64(v2[n-j-1])
}
return fmt.Sprint(sum)
}
示例5: solver
func solver(in *ProblemReader.ProblemReader) string {
nums := in.NNums(2)
board, toWin := nums[0], nums[1]
assert(toWin <= board)
lines := make([]string, board)
for j := 0; j < board; j++ {
line := []byte(in.Line())
if len(line) != board {
log.Fatalf("Expected %#v to be %d long", string(line), board)
}
shiftLine(line)
lines[j] = string(line)
}
return winner(lines, toWin)
}
示例6: solver
func solver(in *ProblemReader.ProblemReader) string {
nums := in.NNums(2)
existing, toCreate := nums[0], nums[1]
tree := newTree()
for j := 0; j < existing; j++ {
tree.add(in.Line())
}
additions := 0
for j := 0; j < toCreate; j++ {
additions += tree.add(in.Line())
}
return fmt.Sprintf("%d", additions)
}
示例7: solver
func solver(in *ProblemReader.ProblemReader) string {
n := in.Num()
wires := make([]Wire, n)
for j := 0; j < n; j++ {
wire := in.NNums(2)
wires[j] = Wire{wire[0], wire[1]}
}
sort.Sort(WireSlice(wires))
cross := 0
for j := 0; j < n; j++ {
for k := j + 1; k < n; k++ {
if wires[k].b < wires[j].b {
cross++
}
}
}
return fmt.Sprintf("%d", cross)
}