Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <fstream>
- #include <iostream>
- using namespace std;
- ifstream cin("cartonase.in");
- ofstream cout("cartonase.out");
- int n , x , y , cer , st , dr , cnt , p , lmax , cate;
- int main()
- {
- cin >> cer >> n;
- for(int i = 1 ; i <= n ; i++)
- {
- cin >> x >> y;
- if(x == dr)
- {
- cate++;
- cnt++;
- }
- else
- {
- if(cnt > lmax) lmax = cnt , p = 0;
- else if(cnt == lmax) p++;
- cnt = 0;
- }
- st = x , dr = y;
- }
- if(cnt > 0)
- {
- if(cnt > lmax) lmax = cnt;
- else if(cnt == lmax) p++;
- }
- if(cer == 1)cout << cate;
- else if(cer == 2) cout << lmax + 1;
- else cout << p + 1;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment