monito2207

Untitled

Oct 11th, 2022
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.42 KB | None | 0 0
  1. #include <cmath>
  2. #include <cstdio>
  3. #include <vector>
  4. #include <iostream>
  5. #include <algorithm>
  6. using namespace std;
  7. const int MAX_SIZE = 100000;
  8.  
  9. int main() {
  10.     int N, win = 0;
  11.     cin >> N;
  12.     int arr[MAX_SIZE];
  13.     for (int i=0; i < N; i++){
  14.         cin >> arr[i];
  15.     }
  16.     for (int i=0; i < N - 1; i++){
  17.         if (arr[i] < arr[i+1]) {win += (arr[i+1]-arr[i]);}
  18.     }
  19.     cout << win;
  20.     return 0;
  21. }
  22.  
Advertisement
Add Comment
Please, Sign In to add comment