Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <set>
- #include <algorithm>
- using namespace std;
- int cnt_all[6001], cnt_after_last_zero[6000];
- int main()
- {
- memset(cnt_all, 0, sizeof cnt_all);
- memset(cnt_after_last_zero, 0, sizeof cnt_after_last_zero);
- bool dali = false;
- while(true) {
- int x;
- cin >> x;
- if(x == 11111) break;
- if(x == 0 and dali) {
- memset(cnt_after_last_zero, 0, sizeof cnt_after_last_zero);
- }
- if(x == 0) {
- dali = true;
- }
- if(x != 0 and dali) {
- cnt_all[x]++;
- cnt_after_last_zero[x]++;
- }
- }
- int maks = -1, minn = 6005;
- for(int i = 6000; i >= 600; i--) {
- cnt_all[i] -= cnt_after_last_zero[i];
- if(cnt_all[i] > 0) {
- maks = max(maks, i);
- minn = min(minn, i);
- }
- }
- cout << maks - minn << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement