0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-23 23:08:47 +00:00

P1190 [NOIP2010 普及组] 接水问题

R52213952
This commit is contained in:
Baoshuo Ren 2021-06-30 15:24:32 +08:00 committed by Baoshuo Ren
parent 7311709fc9
commit a287c8d2bf
Signed by: baoshuo
GPG Key ID: 70F90A673FB1AB68

View File

@ -0,0 +1,27 @@
#include <bits/stdc++.h>
using namespace std;
int n, m, w[10005], p, t, s;
int main() {
cin >> n >> m;
for (int i = 0; i < n; i++) {
cin >> w[i];
}
p = m;
while (p <= n) {
for (int i = 0; i < m; i++) {
w[i]--;
if (!w[i]) {
w[i] = w[p++];
}
}
t++;
}
for (int i = 0; i < m; i++) {
s = max(s, w[i]);
}
cout << t + s << endl;
return 0;
}