diff --git a/S2OJ/1470/1470.cpp b/S2OJ/1470/1470.cpp new file mode 100644 index 00000000..fc1a70bf --- /dev/null +++ b/S2OJ/1470/1470.cpp @@ -0,0 +1,45 @@ +#include +#include +#include +#include + +using std::cin; +using std::cout; +const char endl = '\n'; + +const int N = 1e5 + 5; + +int n, l, s, a[N], b[N]; + +int main() { + std::ios::sync_with_stdio(false); + cin.tie(nullptr); + + cin >> n >> l; + + for (int i = 1; i < n; i++) { + cin >> a[i]; + + s += a[i]; + } + + a[n] = b[0] = s; + for (int i = 0; i < n; i++) { + for (int j = std::min(i + l, n); j > i; j--) { + if (b[j] < a[j]) { + if (b[j] + b[i] <= a[j]) { + b[j] += b[i]; + b[i] = 0; + break; + } else { + b[i] -= a[j] - b[j]; + b[j] = a[j]; + } + } + } + } + + cout << b[n] << endl; + + return 0; +} diff --git a/S2OJ/1470/data/problem.conf b/S2OJ/1470/data/problem.conf new file mode 100644 index 00000000..8585be01 --- /dev/null +++ b/S2OJ/1470/data/problem.conf @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:de0311cc04d3ca03661bc7fd7d620b5c5a8ee593ce57cab9fb41b54a596eab55 +size 179 diff --git a/S2OJ/1470/data/river1.in b/S2OJ/1470/data/river1.in new file mode 100644 index 00000000..2bbd0b8e --- /dev/null +++ b/S2OJ/1470/data/river1.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1c2ac89a3086181bae0662d8f52e4ae91046c94869d80656887dc031b53229f1 +size 14 diff --git a/S2OJ/1470/data/river1.out b/S2OJ/1470/data/river1.out new file mode 100644 index 00000000..d76a596d --- /dev/null +++ b/S2OJ/1470/data/river1.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f0b5c2c2211c8d67ed15e75e656c7862d086e9245420892a7de62cd9ec582a06 +size 2 diff --git a/S2OJ/1470/data/river10.in b/S2OJ/1470/data/river10.in new file mode 100644 index 00000000..c76c05bc --- /dev/null +++ b/S2OJ/1470/data/river10.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c6ffba7561edfc54fd927e9b826065af243572f3460f1466c7cf30107c4fb658 +size 486628 diff --git a/S2OJ/1470/data/river10.out b/S2OJ/1470/data/river10.out new file mode 100644 index 00000000..e0a192db --- /dev/null +++ b/S2OJ/1470/data/river10.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c3686452932c215b5a7e9c35c3ab777ee3bddb7b7bc39377692f65e5393da1c8 +size 9 diff --git a/S2OJ/1470/data/river2.in b/S2OJ/1470/data/river2.in new file mode 100644 index 00000000..1ad59e65 --- /dev/null +++ b/S2OJ/1470/data/river2.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e895a57936942657b2e6cd2bc429748eb6ff5e067752b36ab76b67e84583436e +size 14 diff --git a/S2OJ/1470/data/river2.out b/S2OJ/1470/data/river2.out new file mode 100644 index 00000000..d595cdb8 --- /dev/null +++ b/S2OJ/1470/data/river2.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7de1555df0c2700329e815b93b32c571c3ea54dc967b89e81ab73b9972b72d1d +size 2 diff --git a/S2OJ/1470/data/river3.in b/S2OJ/1470/data/river3.in new file mode 100644 index 00000000..cb8ecd33 --- /dev/null +++ b/S2OJ/1470/data/river3.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9f956927f4a4baea5f5b746e950f7e7eee6d211f6e719b95a8c39b408d5e32d8 +size 14 diff --git a/S2OJ/1470/data/river3.out b/S2OJ/1470/data/river3.out new file mode 100644 index 00000000..cb90f684 --- /dev/null +++ b/S2OJ/1470/data/river3.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:06e9d52c1720fca412803e3b07c4b228ff113e303f4c7ab94665319d832bbfb7 +size 2 diff --git a/S2OJ/1470/data/river4.in b/S2OJ/1470/data/river4.in new file mode 100644 index 00000000..0709a1da --- /dev/null +++ b/S2OJ/1470/data/river4.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4edb2de7c8dc77fba254a2a69422932804a2e62f82a0615f417e9ce2f21a01a4 +size 14 diff --git a/S2OJ/1470/data/river4.out b/S2OJ/1470/data/river4.out new file mode 100644 index 00000000..d76a596d --- /dev/null +++ b/S2OJ/1470/data/river4.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f0b5c2c2211c8d67ed15e75e656c7862d086e9245420892a7de62cd9ec582a06 +size 2 diff --git a/S2OJ/1470/data/river5.in b/S2OJ/1470/data/river5.in new file mode 100644 index 00000000..dd9cf09b --- /dev/null +++ b/S2OJ/1470/data/river5.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5f7bb49fc3472cd9a6aa67d023b28926b4814c9bc836db3388bf4372df4921bc +size 14 diff --git a/S2OJ/1470/data/river5.out b/S2OJ/1470/data/river5.out new file mode 100644 index 00000000..1afab5f7 --- /dev/null +++ b/S2OJ/1470/data/river5.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4355a46b19d348dc2f57c046f8ef63d4538ebb936000f3c9ee954a27460dd865 +size 2 diff --git a/S2OJ/1470/data/river6.in b/S2OJ/1470/data/river6.in new file mode 100644 index 00000000..fc08f497 --- /dev/null +++ b/S2OJ/1470/data/river6.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b6dfb0cf9a84959a7475e25b4f7d49a424d3497ae3daca096c9445f1fe14e7f2 +size 218 diff --git a/S2OJ/1470/data/river6.out b/S2OJ/1470/data/river6.out new file mode 100644 index 00000000..11461333 --- /dev/null +++ b/S2OJ/1470/data/river6.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:19b8d5c59e421f037fe563007c7254eb8d98bc221b278c3db3e5fdbbfd52e273 +size 3 diff --git a/S2OJ/1470/data/river7.in b/S2OJ/1470/data/river7.in new file mode 100644 index 00000000..02cacca4 --- /dev/null +++ b/S2OJ/1470/data/river7.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8daafb30013b6dc919eb1ec486e42d3049d53749732b4f932604ea3d26324dde +size 215 diff --git a/S2OJ/1470/data/river7.out b/S2OJ/1470/data/river7.out new file mode 100644 index 00000000..6a24c034 --- /dev/null +++ b/S2OJ/1470/data/river7.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:20b4c93ea83a73f3033a1fc46b01ff03f90b860b542561d71a043849fe622399 +size 4 diff --git a/S2OJ/1470/data/river8.in b/S2OJ/1470/data/river8.in new file mode 100644 index 00000000..4cf96988 --- /dev/null +++ b/S2OJ/1470/data/river8.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3662b729d8c04eecc22256f5cbceeaa551a80f7d8394519890cb7416d9413fab +size 213 diff --git a/S2OJ/1470/data/river8.out b/S2OJ/1470/data/river8.out new file mode 100644 index 00000000..a964cf3e --- /dev/null +++ b/S2OJ/1470/data/river8.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:565b6c5dfda1c10331dff54981307263d2de6444cd54226a8964a58b1d1e5b0e +size 4 diff --git a/S2OJ/1470/data/river9.in b/S2OJ/1470/data/river9.in new file mode 100644 index 00000000..d20804c2 --- /dev/null +++ b/S2OJ/1470/data/river9.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:cd0307301a5699e59c1c2f9bc9b557d164fb800dd73cc65e1655881dc17ca66c +size 486412 diff --git a/S2OJ/1470/data/river9.out b/S2OJ/1470/data/river9.out new file mode 100644 index 00000000..d44fa798 --- /dev/null +++ b/S2OJ/1470/data/river9.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a14853bbf6fef99cb90f4b3d59b1481d0a246112e749bda0f03ca8589130d794 +size 8