nicuvlad76

398

Oct 25th, 2020
509
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<bits/stdc++.h>
  2. #define N 1005
  3. using namespace std;
  4. ifstream fin("plopi2.in");
  5. ofstream fout("plopi2.out");
  6. int n,v[N],nc,sfin,nrfin;
  7.  
  8. int main()
  9. {
  10.     int i;
  11.     fin>>n;
  12.     for(i=1;i<=n;i++) fin>>v[i];
  13.     nc=v[1];
  14.     for(i=2;i<=n;i++)
  15.     {
  16.        if(nc<v[i])
  17.         {
  18.             sfin+=v[i]-nc;
  19.             v[i]=nc;
  20.             nrfin++;
  21.         }
  22.         else
  23.             if(nc>v[i]) nc=v[i];
  24.     }
  25.     fout<<nrfin<<" "<<sfin;
  26. }
  27.  
RAW Paste Data