Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <map>
- #include <set>
- using namespace std;
- typedef long long ll;
- int main() {
- bool prva_nula = false;
- int tmp_min = 2e9, tmp_max = -2e9;
- int global_min = 2e9, global_max = -2e9;
- for(int i = 0; i < 1000000; i++) {
- int x;
- cin >> x;
- if(x == 11111) {
- break;
- }
- if(x == 0 and !prva_nula) {
- prva_nula = true;
- continue;
- }
- if(x !=0 and prva_nula) {
- tmp_min = min(tmp_min, x);
- tmp_max = max(tmp_max, x);
- }
- if(x == 0) {
- global_max = max(global_max, tmp_max);
- global_min = min(global_min, tmp_min);
- tmp_max = -2e9;
- tmp_min = 2e9;
- }
- }
- cout << global_max - global_min << endl;
- return 0;
- }
- // 2 1 3 3
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement