Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- int main()
- {
- long long int x,i,ct=0,sum=0,count=0;
- scanf("%lld",&x);
- int n[x],cpy[x];
- for(i=0; i<x; i++)
- {
- scanf("%lld",&n[i]);
- cpy[i]=n[i];
- sum = sum+n[i];
- }
- i=0;
- if(n[0]%2!=0)
- {
- while(i<x)
- {
- if(n[i]%2!=0)
- {
- if(n[i]==0)
- {break;}
- ct++;
- n[i]=n[i]-1;
- i++;
- }
- else if(n[i]%2==0)
- {
- if(n[i]==0)
- {break;}
- ct++;
- n[i]=n[i]-1;
- i--;
- }
- }
- }
- else if(n[0]%2==0)
- {
- while(i<x)
- {
- if(n[i]%2==0)
- {
- if(n[i]==0)
- {break;}
- ct++;
- n[i]=n[i]-1;
- i++;
- }
- else if(n[i]%2!=0)
- {
- if(n[i]==0)
- {break;}
- ct++;
- n[i]=n[i]-1;
- i--;
- }
- }
- }
- for(i=0; i<x; i++)
- {
- if(n[i]!=cpy[i])
- count++;
- }
- printf("%lld %lld\n",count,sum-ct);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement