ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1581. Teamwork

here is my solution I've got AC 0,015 209kb
Posted by yaho0o0 7 Apr 2009 21:03
#include <iostream>
using namespace std;
int main()
{
    int n,a[1024],br=1,i;
    cin>>n;
    cin>>a[1];
    if(n==1)
    {
        cout<<"1 "<<a[1];
    }
    for(i=2;i<=n;i++)
    {
        cin>>a[i];
        if(a[i]==a[i-1])
        {
            br++;
        }
        if(a[i]!=a[i-1])
        {
            cout<<br<<" "<<a[i-1]<<" ";
            br=1;
        }
        if(i==n)
        {
            cout<<br<<" "<<a[i];
        }
    }
    cout<<endl;
    return 0;
}

Edited by author 07.04.2009 21:12