You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
801 B
28 lines
801 B
2 years ago
|
#include <bits/stdc++.h>
|
||
|
using namespace std;
|
||
|
|
||
|
const int N = 10010, M = 110;
|
||
|
|
||
|
int n, m;
|
||
|
int w[N]; // 每个同学的接水时间
|
||
|
int q[M]; // 每个水龙头的结束时间
|
||
|
|
||
|
int main() {
|
||
|
cin >> n >> m;
|
||
|
for (int i = 0; i < n; i++) cin >> w[i];
|
||
|
|
||
|
for (int i = 0; i < n; i++) { // 每个同学
|
||
|
int t = 0;
|
||
|
for (int j = 0; j < m; j++) // 每个水龙头
|
||
|
if (q[j] < q[t]) // 求出当前结束时间最早的水龙头编号
|
||
|
t = j;
|
||
|
|
||
|
q[t] += w[i]; // 那么我们就将当前同学安排在这个水龙头的位置上,然后将该水龙头的结束时间加上当前同学的接水时间。
|
||
|
}
|
||
|
|
||
|
int res = 0;
|
||
|
for (int i = 0; i < m; i++) res = max(res, q[i]);
|
||
|
|
||
|
cout << res << endl;
|
||
|
return 0;
|
||
|
}
|