Advertisement
Guest User

Problema gebaila 2

a guest
Feb 25th, 2020
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. #include<fstream>
  2. #include<algorithm>
  3.  
  4. using namespace std;
  5.  
  6. int n, k, i, aux, nr, S;
  7. int main()
  8. {
  9.     ifstream f("plopi2.in");
  10.     ofstream g("plopi2.out");
  11.     f >> n;
  12.     f >> aux;
  13.     for(i = 2; i <= n; i ++)
  14.     {
  15.         f >> nr;
  16.         if(nr > aux)
  17.         {
  18.             S = S + nr - aux;
  19.             ++ k;
  20.         } else
  21.         aux = nr;
  22.     }
  23.     g << k << " " << S;
  24.  
  25.     return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement