Advertisement
Guest User

Untitled

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