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.
2 parents c2fee78 + 8787e93 commit 437e6d3Copy full SHA for 437e6d3
khj20006/202502/18 BOJ G4 관악산 등산.md
@@ -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