Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- typedef long long ll;
- #define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
- #define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);
- #define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
- int main() {
- optimize();
- int n;
- cin >> n;
- int a[n];
- for (int i = 0; i < n; ++i) cin >> a[i];
- int cnt = 1;
- bool started = 0;
- for (int i = 1; i < n; ++i) {
- if (a[i] == a[i - 1]) cnt++;
- else {
- if (started) cout << " ";
- started = 1;
- cout << cnt << " " << a[i - 1];
- cnt = 1;
- }
- }
- if (started) cout << " ";
- started = 1;
- cout << cnt << " " << a[n - 1] << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement