Skip to content

Commit 437e6d3

Browse files
authored
Merge pull request #146 from AlgorithmWithGod/khj20006
[20250218] BOJ / G4 / 관악산 등산 / 권혁준
2 parents c2fee78 + 8787e93 commit 437e6d3

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
```cpp
2+
3+
#include <iostream>
4+
#include <vector>
5+
#include <algorithm>
6+
using namespace std;
7+
8+
int main(){
9+
cin.tie(0)->sync_with_stdio(0);
10+
11+
int D[5001]{}, H[5001]{};
12+
vector<vector<int>> V(5001);
13+
pair<int, int> A[5001]{};
14+
15+
int N, M;
16+
cin>>N>>M;
17+
for(int i=1;i<=N;i++) cin>>H[i], A[i] = {H[i], i};
18+
sort(A+1, A+N+1, greater<>());
19+
20+
for(int a,b;M--;){
21+
cin>>a>>b;
22+
if(H[a] < H[b]) swap(a,b);
23+
V[a].push_back(b);
24+
}
25+
26+
for(int i=1;i<=N;i++) {
27+
for(int j:V[A[i].second]) D[j] = max(D[j], D[A[i].second] + 1);
28+
}
29+
30+
for(int i=1;i<=N;i++) cout<<D[i]+1<<'\n';
31+
32+
}
33+
34+
```

0 commit comments

Comments
 (0)