Advertisement
Guest User

Untitled

a guest
Apr 6th, 2020
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.59 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <algorithm>
  4.  
  5. using namespace std;
  6. //
  7. //class Unit {
  8. //public:
  9. //    Unit(int health) : mHealth(health) {
  10. //        cout << "Unit has benn created!" << '\n';
  11. //    }
  12. //    ~Unit() {
  13. //        cout << "Unit has been destroyed!" << '\n';
  14. //    }
  15. //protected:
  16. //    int mHealth;
  17. //};
  18. //
  19. //class Archer : virtual public Unit {
  20. //public:
  21. //    Archer(int health) : Unit(health) { cout << "Archer has been created!" << '\n'; }
  22. //    ~Archer() { cout << "Archer has been destroyed!" << '\n'; }
  23. //protected:
  24. //};
  25. //
  26. //class Wizard : virtual public Unit {
  27. //public:
  28. //    Wizard(int health) : Unit(health) { cout << "Wizard has been created!" << '\n'; }
  29. //    ~Wizard() { cout << "Wizard has been destroyed!" << '\n'; }
  30. //protected:
  31. //};
  32. //
  33. //class WizardArcher : public Archer, public Wizard {
  34. //public:
  35. //    WizardArcher(int health) : Unit(health), Archer(health), Wizard(health) { cout << "WizardArcher has been created!" << '\n'; }
  36. //    ~WizardArcher() { cout << "WizardArcher has been destroyed!" << '\n'; }
  37. //protected:
  38. //};
  39. //
  40. //class Animal {
  41. //public:
  42. //    virtual void makeSound() = 0;
  43. //};
  44. //
  45. //class Dog : public Animal {
  46. //public:
  47. //    void makeSound() override {
  48. //        cout << "Wow" << '\n';
  49. //    }
  50. //};
  51. //
  52. //class Fish : public Animal {
  53. //public:
  54. //    void makeSound() override {
  55. //        cout << "..." << '\n';
  56. //    }
  57. //};
  58. //
  59. //class Unicorn : public Animal {
  60. //public:
  61. //    void makeSound() override {
  62. //        cout << "Ego-go-go/ihohohohoho" << '\n';
  63. //    }
  64. //};
  65. //
  66. //int main() {
  67. ////    WizardArcher wizardArcher(50);
  68. //    Dog dog;
  69. //}
  70.  
  71. int main() {
  72. //    int testsCount;
  73. //    cin >> testsCount;
  74. //
  75. //    for (int i = 0; i < testsCount; ++i) {
  76. //        int n;
  77. //        cin >> n;
  78. //
  79. //        vector<int> firstArray (n);
  80. //        vector<int> secondArray (n);
  81. //
  82. //        for (int &value : firstArray) {
  83. //            cin >> value;
  84. //        }
  85. //        for (int &value : secondArray) {
  86. //            cin >> value;
  87. //        }
  88. //
  89. //        sort(firstArray.begin(), firstArray.end());
  90. //        sort(secondArray.begin(), secondArray.end());
  91. //
  92. //        for (int &value : firstArray) {
  93. //            cout << value << ' ';
  94. //        }
  95. //        cout << '\n';
  96. //        for (int &value : secondArray) {
  97. //            cout << value << ' ';
  98. //        }
  99. //        cout << '\n';
  100. //    }
  101. //    int testsCount;
  102. //    cin >> testsCount;
  103. //
  104. //    for (int i = 0; i < testsCount; ++i) {
  105. //        int n;
  106. //        cin >> n;
  107. //
  108. //        vector<int> values(n);
  109. //        for (int &value : values) {
  110. //            cin >> value;
  111. //        }
  112. //
  113. //        sort(values.begin(), values.end());
  114. //        reverse(values.begin(), values.end());
  115. //        for (int value : values) {
  116. //            cout << value << ' ';
  117. //        }
  118. //        cout << '\n';
  119. //
  120. //    }
  121. //    int n;
  122. //    cin >> n;
  123. //    vector<int> bArray(n);
  124. //    for (int &value : bArray) {
  125. //        cin >> value;
  126. //    }
  127. //
  128. //    // b_i = a_i - x_i
  129. //    // a_i = b_i + x_i
  130. //    // have: b_i
  131. //    // find: x_i
  132. //    // have a_1 ... a_{i - 1}
  133. //    // have : x_{i+1} = max(0, a_1, ....., a_i)
  134. //
  135. //    // we have: [b_1, ..., b_n]
  136. //    // we have: [a_1, ..., a_{i-1}]
  137. //    // find: a_{i}
  138. //    // a_i = b_i + x_i
  139. //    // find: x_i
  140. //    // x_i = max(0, a_1, ..., a_{i-1})
  141. //    // have: x_i
  142. //    vector<int> aArray(n);
  143. //    int x_i = 0;
  144. //    for (int i = 0; i < n; ++i) {
  145. //        aArray[i] = bArray[i] + x_i;
  146. //        cout << aArray[i] << ' ';
  147. //        x_i = max(x_i, aArray[i]);
  148. //    }
  149.  
  150.  
  151. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement