【解題】Zerojudge d424. 00105 - The Skyline Problem

題目連結

d424. 00105 - The Skyline Problem

參考解答

防雷

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <bits/stdc++.h>
using namespace std;

int height[10005] = {0};

int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
int l, h, r, mx = 0, mn = 10000;
while (cin >> l >> h >> r) {
mn = min(mn, l);
mx = max(mx, r);
for (int i = l; i < r; i++) height[i] = max(h, height[i]);
}
int record = -1;
for (int i = mn; i <= mx; i++) {
if (height[i] != record) {
cout << i << ' ' << height[i] << ' ';
record = height[i];
}
}
cout << '\n';
}
標籤(Tags)

解題, Zerojudge, 陣列, CPE