Skip to content

Commit

Permalink
CF11A
Browse files Browse the repository at this point in the history
  • Loading branch information
EndlessCheng committed Feb 22, 2024
1 parent a99ee97 commit efd5230
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
25 changes: 25 additions & 0 deletions main/1-99/11A.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package main

import (
"bufio"
. "fmt"
"io"
)

// https://space.bilibili.com/206214
func cf11A(_r io.Reader, out io.Writer) {
in := bufio.NewReader(_r)
var n, d, pre, v, ans int
for Fscan(in, &n, &d, &pre); n > 1; n-- {
Fscan(in, &v)
if v <= pre {
k := (pre-v)/d + 1
ans += k
v += k * d
}
pre = v
}
Fprint(out, ans)
}

//func main() { cf11A(os.Stdin, os.Stdout) }
20 changes: 20 additions & 0 deletions main/1-99/11A_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Generated by copypasta/template/generator_test.go
package main

import (
"github.com/EndlessCheng/codeforces-go/main/testutil"
"testing"
)

// http://codeforces.com/problemset/problem/11/A
// https://codeforces.com/problemset/status/11/problem/A
func Test_cf11A(t *testing.T) {
testCases := [][2]string{
{
`4 2
1 3 3 2`,
`3`,
},
}
testutil.AssertEqualStringCase(t, testCases, 0, cf11A)
}

0 comments on commit efd5230

Please sign in to comment.