We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 1c35281 commit 0eae05fCopy full SHA for 0eae05f
CSES-Problem-Set/searching-sorting/movie-festival-II.cpp
@@ -0,0 +1,34 @@
1
+// link : https://cses.fi/problemset/task/1632/
2
+
3
+#include<bits/stdc++.h>
4
+#define int long long
5
+using namespace std;
6
+#define MOD 1000000007
7
8
+signed main() {
9
+ ios_base::sync_with_stdio(0);
10
+ cin.tie(0);
11
+int n,k;
12
+cin>>n>>k;
13
+vector<pair<int,int>>vec(n);
14
+for(auto &it:vec){
15
+ cin>>it.second>>it.first;
16
+}
17
+sort(vec.begin(),vec.end());
18
+multiset<int>mp;
19
+int cnt=0;
20
+for(auto it:vec){
21
+ auto up=mp.upper_bound(it.second);
22
+ if(up!=mp.begin()){
23
+ up--;
24
+ mp.erase(up);
25
+ }
26
+ if(size(mp)<k){
27
+ mp.insert(it.first);
28
+ cnt++;
29
30
31
+cout<<cnt<<endl;
32
33
+ return 0;
34
0 commit comments