mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-11-23 17:28:47 +00:00
parent
9df2203d05
commit
6b2c7a391e
45
S2OJ/1470/1470.cpp
Normal file
45
S2OJ/1470/1470.cpp
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
#include <iostream>
|
||||||
|
#include <cstring>
|
||||||
|
#include <limits>
|
||||||
|
#include <queue>
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
BIN
S2OJ/1470/data/problem.conf
(Stored with Git LFS)
Normal file
BIN
S2OJ/1470/data/problem.conf
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1470/data/river1.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1470/data/river1.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1470/data/river1.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1470/data/river1.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1470/data/river10.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1470/data/river10.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1470/data/river10.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1470/data/river10.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1470/data/river2.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1470/data/river2.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1470/data/river2.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1470/data/river2.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1470/data/river3.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1470/data/river3.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1470/data/river3.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1470/data/river3.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1470/data/river4.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1470/data/river4.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1470/data/river4.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1470/data/river4.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1470/data/river5.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1470/data/river5.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1470/data/river5.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1470/data/river5.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1470/data/river6.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1470/data/river6.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1470/data/river6.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1470/data/river6.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1470/data/river7.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1470/data/river7.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1470/data/river7.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1470/data/river7.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1470/data/river8.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1470/data/river8.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1470/data/river8.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1470/data/river8.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1470/data/river9.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1470/data/river9.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1470/data/river9.out
(Stored with Git LFS)
Normal file
BIN
S2OJ/1470/data/river9.out
(Stored with Git LFS)
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user