Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int main()
- {
- int global_max = 0, global_min = 6001;
- int tmp_max = 0, tmp_min = 6001;
- int x;
- int nuli = 0;
- while(cin >> x) {
- if(x == 11111) {
- break;
- }
- if(x == 0 and nuli == 0) {
- nuli = 1;
- continue;
- }
- if(x != 0 and nuli > 0) {
- tmp_max = max(tmp_max, x);
- tmp_min = min(tmp_min, x);
- }
- if(x == 0) {
- global_max = max(global_max, tmp_max);
- global_min = min(global_min, tmp_min);
- tmp_max = 0;
- tmp_min = 6001;
- }
- }
- cout << global_max - global_min << endl;
- return 0;
- }
- // 650 1500 0 600 1000 2000 0 800 1500 0 1500 1300 1400 11111
- /*
- tmp_min = 800
- tmp_max = 1500
- global_min = 600
- global_max = 2000
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement