Advertisement
willy108

Operations on array

Jan 1st, 2022
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.30 KB | None | 0 0
  1. ```cpp
  2. #include <iostream>
  3. #include <vector>
  4. using namespace std;
  5. int main(){
  6. int n;
  7. vector<int> arr(n);
  8. for(int i = 0; i<n; i++) cin >> arr[i];
  9. ll ans = 0;
  10. for(int i = 1; i<n; i++){
  11. if(a[i] < a[i-1]){
  12. ans += a[i-1] - a[i];
  13. }
  14. }
  15. cout << ans << "\n";
  16. return 0;
  17. }
  18. ```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement