mirror of
https://github.com/lWolvesl/leetcode.git
synced 2026-01-13 02:38:37 +08:00
init
This commit is contained in:
13
25/06/2929.go
Normal file
13
25/06/2929.go
Normal file
@@ -0,0 +1,13 @@
|
||||
package main
|
||||
|
||||
func distributeCandies(n int, limit int) int64 {
|
||||
var res int64 = 0
|
||||
for i := 0; i <= min(n, limit); i++ {
|
||||
last := n - i
|
||||
if last > 2*limit {
|
||||
continue
|
||||
}
|
||||
res += int64(min(last, limit) - max(0, last-limit) + 1)
|
||||
}
|
||||
return res
|
||||
}
|
||||
Reference in New Issue
Block a user