Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <bits/stdc++.h>
- //%lld
- typedef long long ll;
- using namespace std;
- ll vetor[1000000], aux;
- int visitado[1000000];
- int main(){
- freopen("in.txt", "r", stdin);
- //freopen("out.txt", "w", stdout);
- int n, t = 0, cnt = 1;
- cin>>n;
- aux = 0;
- for(int i = 0;i<n;i++){
- cin>>vetor[i];
- aux+=vetor[i];
- }
- bool vai = true;
- while(vai){
- if(vetor[t]%2==0){//esquerda
- if(vetor[t]>=1)aux-=1;
- if(vetor[t]>=1)vetor[t]--;
- if(t==0){
- vai = false;
- }else{
- if(!visitado[t])cnt++;
- visitado[t] = 1;
- t--;
- }
- }else{//direita
- if(vetor[t]>=1)aux-=1;
- if(vetor[t]>=1)vetor[t]--;
- if(t==n-1){
- vai = false;
- }else{
- if(!visitado[t])cnt++;
- visitado[t] = 1;
- t++;
- }
- }
- }
- cout<<cnt<<" "<<aux<<endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement