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 717146b + 8cdb072 commit 191ed2fCopy full SHA for 191ed2f
khj20006/202502/25 BOJ S2 창고 다각형.md
@@ -0,0 +1,30 @@
1
+```cpp
2
+
3
+#include <iostream>
4
+#include <algorithm>
5
+using namespace std;
6
7
+int main()
8
+{
9
+ cin.tie(0)->sync_with_stdio(0);
10
11
+ int N, Y[1001]{}, Z[1001]{};
12
+ cin >> N;
13
+ for (int i = 0, a, b; i < N; i++) {
14
+ cin >> a >> b;
15
+ Y[a] = b;
16
+ }
17
18
+ for (int i = 1; i <= 1000; i++) Z[i] = max(Z[i - 1], Y[i]);
19
20
+ int ans = 0, from_right = 0;
21
+ for (int i = 1000; i >= 1; i--) {
22
+ from_right = max(from_right, Y[i]);
23
+ Z[i] = min(Z[i], from_right);
24
+ ans += Z[i];
25
26
+ cout << ans;
27
28
+}
29
30
+```
0 commit comments