Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <algorithm>
- using namespace std;
- const int INF = 2e9;
- int main() {
- int height;
- int res_max = -INF, res_min = INF;
- int tmp_max = -INF, tmp_min = INF;
- bool after_first_zero = false;
- while (cin >> height && height != 11111) {
- if(height == 0) {
- after_first_zero = true;
- res_max = max(res_max, tmp_max);
- res_min = min(res_min, tmp_min);
- tmp_max = -INF;
- tmp_min = INF;
- }
- else if(after_first_zero) {
- tmp_max = max(tmp_max, height);
- tmp_min = min(tmp_min, height);
- }
- }
- cout << res_max - res_min << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement