Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- pair <int, int> v[1004];
- pair<int, int> x[1004];
- int main()
- {
- int n, i, nrcutiidate=0, obiectedate=0, ajut=0, nrcutiiionel;
- cin>>n;
- nrcutiiionel=n;
- for(i=1; i<=n; i++)
- {
- cin>>v[i].second;
- v[i].first=i;
- x[i].first=i;
- x[i].second=v[i].second;
- }
- while(v[2].second!=0)
- {
- ajut=0;
- for(i=1; i<=n/2; i++)
- {
- v[i].second+=v[n-ajut].second;
- ajut++;
- }
- for(i=n/2+1; i<=n; i++)
- {
- v[i].second=0;
- }
- if(n%2==0)
- {
- nrcutiidate+=2;
- obiectedate=obiectedate+v[n/2].second+v[n/2+1].second;
- for(i=n/2; i<=n-1; i++)
- {
- v[i].second=v[i+1].second;
- }
- for(i=n/2+1; i<=n-1; i++)
- {
- v[i].second=v[i+1].second;
- }
- n-=2;
- n/=2;
- }
- else
- {
- nrcutiidate++;
- obiectedate=obiectedate+v[n/2+1].second;
- for(i=n/2+1; i<=n-1; i++)
- {
- v[i].second=v[i+1].second;
- }
- n-=1;
- n/=2;
- }
- }
- cout<<nrcutiidate<<' '<<obiectedate<<endl<<n<<' '<<v[1].second;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment