Skip to content

Commit ca2b77b

Browse files
committed
solved 10775
1 parent c4f45de commit ca2b77b

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

10000/10775/10775.cpp

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#include <bits/stdc++.h>
2+
using namespace std;
3+
4+
int G, P, i, ans, available_gate[100001];
5+
6+
int getAvailableGate(int n){
7+
if(available_gate[n] == n) return n;
8+
9+
return available_gate[n] = getAvailableGate(available_gate[n]);
10+
}
11+
12+
int main() {
13+
ios::sync_with_stdio(false); cin.tie(NULL);
14+
ans = 0;
15+
16+
cin >> G >> P;
17+
for(i=0;i<=G;i++) available_gate[i]=i;
18+
for(i=0;i<P;i++){
19+
int g, t;
20+
cin >> g;
21+
22+
t = getAvailableGate(g);
23+
if(t) {
24+
available_gate[t] = t - 1;
25+
ans++;
26+
} else break;
27+
}
28+
29+
cout << ans << "\n";
30+
31+
return 0;
32+
}

0 commit comments

Comments
 (0)