Advertisement
NOBLE-_-MAN

Задача B on c++

Oct 10th, 2020
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.46 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. using namespace std;
  4.  
  5. int main(){
  6.     int num;
  7.     cin >> num;
  8.     vector <int> list1;
  9.     int diff;
  10.     for (int n=0; n<num; n++){
  11.         int t;
  12.         cin >> t;
  13.         list1.push_back(t);
  14.     }
  15.     for (int k=num-1; k>0; k--){
  16.         if (list1[k-1] < list1[k]){
  17.             diff = list1[k]-list1[k-1];
  18.             list1[k] = diff-(diff/2+diff%2);
  19.             list1[k-1] = diff/2+diff%2;
  20.         }    
  21.     }
  22.     for (int n=0; n<num; n++){
  23.         cout << list1[n] << " ";
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement