[BOJ] 공항

Time Lapse :NONE

10775.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
#include <iostream>
#include <list>
#include <map>
#include <unordered_map>
#include <vector>
#include <stack>
#include <unordered_set>
#include <set>

using namespace std;
int g, p;
int n, res(0);
set<int> s;
int main() {
scanf("%d%d",&g,&p);
for(int i = 1; i <= p; i++) s.insert(i);
while(p--) {
scanf("%d",&n);
auto it = s.upper_bound(n);
if(it == s.begin()) break;

s.erase(prev(it));
res++;
}
cout<<res;
}
Author: Song Hayoung
Link: https://songhayoung.github.io/2021/08/06/PS/BOJ/10775/
Copyright Notice: All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.