Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- using namespace std;
- int main(){
- int num;
- cin >> num;
- vector <int> list1;
- int diff;
- for (int n=0; n<num; n++){
- int t;
- cin >> t;
- list1.push_back(t);
- }
- for (int k=num-1; k>0; k--){
- if (list1[k-1] < list1[k]){
- diff = list1[k]-list1[k-1];
- list1[k] = diff-(diff/2+diff%2);
- list1[k-1] = diff/2+diff%2;
- }
- }
- for (int n=0; n<num; n++){
- cout << list1[n] << " ";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement