-
Notifications
You must be signed in to change notification settings - Fork 1
/
03985.cpp
48 lines (41 loc) · 874 Bytes
/
03985.cpp
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
44
45
46
47
48
#include <iostream>
#include <vector>
using namespace std;
void solve(void) {
int l; cin >> l;
int n; cin >> n;
vector<int> p(n), k(n);
for (int i=0; i<n; i++) cin >> p[i] >> k[i];
int big = 0, big_idx = -1;
for (int i=0; i<n; i++) {
if (k[i]-p[i]+1 > big) {
big = k[i]-p[i]+1;
big_idx = i+1;
}
}
cout << big_idx << "\n";
vector<int> cake(l, 0);
for (int i=0; i<n; i++) {
for (int j=p[i]; j<=k[i]; j++) {
if (cake[j] == 0) cake[j] = i+1;
}
}
vector<int> real(n, 0);
for (int i=0; i<l; i++) {
if (cake[i] != 0) real[cake[i]-1]++;
}
big = 0; big_idx = -1;
for (int i=0; i<n; i++) {
if (real[i] > big) {
big = real[i];
big_idx = i+1;
}
}
cout << big_idx << "\n";
}
int main(void) {
ios::sync_with_stdio(false);
cin.tie(nullptr); cout.tie(nullptr);
solve();
return 0;
}