UVa105

題目:
https://onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=3&page=show_problem&problem=41

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include <bits/stdc++.h>

using namespace std;

int main(){
ios::sync_with_stdio(0);
cin.tie(0);

int l, h, r;
int arr[10005] = {0};
while(cin >> l >> h >> r){
for(int i=l; i<r; ++i){
if(arr[i] < h) arr[i] = h;
}
}

bool first = true;
for(int i=0; i<10004; ++i){
if(arr[i] != arr[i+1]){
if(first) first = false;
else cout << ' ';

cout << i+1 << ' ' << arr[i+1];
}
}
cout << '\n';

return 0;
}