daily pastebin goal
81%
SHARE
TWEET

Untitled

a guest Mar 18th, 2019 56 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. {
  5.     int N,n,sum,k=0,j=0,maxt,maxk=0;
  6.     cin>>N;
  7.     int t[N][N];
  8.     n=N;
  9.     while(n)
  10.     {
  11.         for(int i=0;i<=j;i++)
  12.             cin>>t[j][i];
  13.         j++;
  14.         n-=j;
  15.     }
  16.     j--;
  17.     maxt=t[j][0];
  18.     for(int i=1;i<j;i++)
  19.     {
  20.         if(t[j][i]>maxt)
  21.         {
  22.             maxt=t[j][i];
  23.             maxk=i;
  24.         }
  25.     }
  26.     sum=t[j][maxk];
  27.     cout<<maxk<<endl;
  28.     while(j--)
  29.     {
  30.         if(maxk)
  31.         {
  32.             if(maxk=j) maxk--;
  33.             else
  34.             {
  35.                 if(t[j][maxk-1]>t[j][maxk]) maxk--;
  36.             }
  37.         }
  38.         sum+=t[j][maxk];
  39.     }
  40.     cout<<sum<<endl;
  41.     return 0;
  42. }
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