daily pastebin goal
12%
SHARE
TWEET

Untitled

a guest Dec 16th, 2018 71 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. using namespace std;
  3. int main(){
  4.     int n;
  5.     cin>>n;
  6.     int array[n+1];
  7.     array[n]=0;
  8.     for(int i=0;i<n;i++){
  9.         cin>>array[i];
  10.     }
  11.     int cont=0;
  12.     int finale=1;
  13.     int o=0;
  14.     int s;
  15.     while(finale==1){
  16.         s=o+1;
  17.        while(array[s]>0||array[o]>0){
  18.         array[s]--;
  19.         s++;
  20.        }
  21.        if(array[o]>0)
  22.             cont++;
  23.        array[o]--;
  24.        if(array[o]<1)
  25.             o++;
  26.        if(o==n-1&&array[o]==0)
  27.             finale=0;
  28.     }
  29.     cout<<cont;
  30.     return 0;
  31. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top