-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGuides touristiques.cpp
44 lines (40 loc) · 1.07 KB
/
Guides touristiques.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
#include <bits/stdc++.h>
using namespace std;
bool compare(const pair<int, int> &a, const pair<int, int> &b) {
if (a.first == b.first) return a.second < b.second;
return a.first < b.first;
}
bool guideEstOccupe(vector<pair<int, int>> &G, pair<int, int> &I) {
if (G.empty()) {
G.push_back(I);
return false;
} else if (I.first >= G.back().second) {
G.push_back(I);
return false;
}
return true;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int nbGuides, nbGroupes;
cin >> nbGuides >> nbGroupes;
vector<pair<int, int>> emploi[nbGuides], intervalles;
for (int i = 0; i < nbGroupes; ++i) {
pair<int, int> temp;
cin >> temp.first >> temp.second;
intervalles.push_back(temp);
}
sort(intervalles.begin(), intervalles.end(), compare);
for (int i = 0; i < nbGroupes; ++i) {
int g = 0;
while (g < nbGuides && guideEstOccupe(emploi[g], intervalles[i])) g++;
if (g == nbGuides) {
cout << 0;
return 0;
}
}
cout << 1;
return 0;
}