-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path32989.cpp
More file actions
43 lines (35 loc) · 1.04 KB
/
32989.cpp
File metadata and controls
43 lines (35 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
int n, m;
cin >> n >> m;
vector<vector<int>> runner_times(n, vector<int>(m));
for(int i = 0; i < n; i++)
for(int j = 0; j < m; j++)
cin >> runner_times[i][j];
vector<int> bottles(m, 0);
for(int r = 0; r < m; r++) {
vector<pair<int,int>> events;
for(int i = 0; i < n; i++) {
int start = 0;
for(int k = 0; k < r; k++)
start += runner_times[i][k];
int end = start + runner_times[i][r];
events.push_back({start, 1});
events.push_back({end, -1});
}
sort(events.begin(), events.end());
int curr = 0, max_count = 0;
for(auto &e : events) {
curr += e.second;
max_count = max(max_count, curr);
}
bottles[r] = max_count;
}
for(int i = 0; i < m; i++)
cout << bottles[i] << " ";
cout << "\n";
return 0;
}