commit 194918e631e5172d0cab393d843a10bcc93fc3f5
parent 9332fdbfec0299adb4eaa88242c29de6f846b863
Author: superpozycja <anna@superpozycja.net>
Date: Sun, 27 Oct 2024 14:28:59 +0100
solve movie festival
Diffstat:
1 file changed, 45 insertions(+), 0 deletions(-)
diff --git a/sorting_and_searching/movie_festival.cpp b/sorting_and_searching/movie_festival.cpp
@@ -0,0 +1,45 @@
+#include <bits/stdc++.h>
+
+using namespace std;
+
+using ui = unsigned int;
+using l = long;
+using ul = unsigned long;
+using ll = long long;
+using ull = unsigned long long;
+
+using vi = vector<int>;
+using vui = vector<ui>;
+using vl = vector<l>;
+using vul = vector<ul>;
+using vll = vector<ll>;
+using vull = vector<ull>;
+
+void solve()
+{
+ int n;
+ cin >> n;
+ vector<pair<int, int>> m;
+ for (int i = 0; i < n; i++) {
+ int s, e;
+ cin >> s >> e;
+ m.push_back({e, s});
+ }
+ sort(m.begin(), m.end());
+ int t = 0, res = 0;
+ for (auto x : m) {
+ if (x.second < t) {
+ continue;
+ }
+ t = x.first;
+ res++;
+ }
+ cout << res << "\n";
+}
+
+int main()
+{
+ ios::sync_with_stdio(0);
+ cin.tie(0);
+ solve();
+}