Advertisement
Guest User

B Innopolis

a guest
Nov 22nd, 2020
472
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.28 KB | None | 0 0
  1. //나는 가상 소녀들에게 큰 호감이 있습니다.
  2.  
  3. #include <iostream>
  4. #include <cmath>
  5. #include <algorithm>
  6. #include <stdio.h>
  7. #include <cstring>
  8. #include <string>
  9. #include <cstdlib>
  10. #include <vector>
  11. #include <bitset>
  12. #include <map>
  13. #include <chrono>
  14. #include <functional>
  15. #include <unordered_set>
  16. #include <unordered_map>
  17. #include <numeric>
  18. #include <queue>
  19. #include <ctime>
  20. #include <stack>
  21. #include <set>
  22. #include <list>
  23. #include <deque>
  24. #include <iomanip>
  25. #include <sstream>
  26. #include <fstream>
  27. #include <stdarg.h>
  28. #include <utility>
  29.  
  30. using namespace std;
  31.  
  32. #define pb push_back
  33. #define mp make_pair
  34. #define ll long long
  35. #define ull unisgned long long
  36. #define ld long double
  37. #define all(a) a.begin(), a.end()
  38. #define SORT(a) sort(all(a))
  39. #define pii pair<int, int>
  40. #define tii triple<int, int, int>
  41. #define e 1e-7
  42. #define PI acos(-1)
  43. #define sz(a) (int)(a.size())
  44. #define inf 1e17
  45. #define vi vector<int>
  46. #define F first
  47. #define S second
  48. #define rng(x) for(int _ = 0; _ < (x); _++)
  49. #define rngi(i, x) for(int i = 0; i < (x); i++)
  50. #define rngsi(s, i, x) for(int i = (s); i <(x); i++)
  51. #define int long long
  52. #define problem "a"
  53.  
  54. template<typename A, typename B, typename C>
  55. struct triple {
  56. A X;
  57. B Y;
  58. C Z;
  59. triple(A a = 0, B b = 0, C c = 0) :X(a), Y(b), Z(c) {}
  60. };
  61. template<typename A, typename B, typename C>
  62. triple<A, B, C> make_triple(A a = 0, B b = 0, C c = 0) {
  63. return triple<A, B, C>(a, b, c);
  64. }
  65. template<typename A, typename B, typename C>
  66. bool operator<(const triple<A, B, C>& a, const triple<A, B, C>& b) {
  67. if (a.X != b.X)
  68. return a.X < b.X;
  69. if (a.Y != b.Y)
  70. return a.Y < b.Y;
  71. return a.Z < b.Z;
  72. }
  73. template<typename T, typename SS>
  74. ostream& operator<<(ostream& ofs, const pair<T, SS>& p) {
  75. ofs << "( " << p.F << " , " << p.S << " )";
  76. return ofs;
  77. }
  78. template<typename T>
  79. void print(T a) {
  80. for (auto i : a)
  81. cout << i << ' ';
  82. cout << '\n';
  83. }
  84. template<typename T>
  85. T max(T a, T b, T c) {
  86. return max(a, max(b, c));
  87. }
  88. template<typename T>
  89. T min(T a, T b, T c) {
  90. return min(a, min(b, c));
  91. }
  92. template<typename T, typename D>
  93. D min(T a) {
  94. return *min_element(all(a));
  95. }
  96. template<typename T, typename D>
  97. D max(T a) {
  98. return *max_element(all(a));
  99. }
  100. struct custom_hash {
  101. static uint64_t splitmix64(uint64_t x) {
  102. x += 0x9e3779b97f4a7c15;
  103. x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
  104. x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
  105. return x ^ (x >> 31);
  106. }
  107.  
  108. size_t operator()(uint64_t x) const {
  109. static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
  110. return splitmix64(x + FIXED_RANDOM);
  111. }
  112. };
  113. void solve() {
  114. int n; cin >> n;
  115. vi a(n); rngi(i, n) cin >> a[i];
  116. int v = *max_element(all(a));
  117. rngi(i, n) a[i] = v - a[i];
  118. int ans = 0, u = 0, r = 0;
  119. rngi(i, n) {
  120. if (a[i] > u) ans += a[i] - u;
  121.  
  122. u = a[i];
  123. }
  124. cout << ans << '\n';
  125. };
  126. signed main()
  127. {
  128. if (0) {
  129. freopen(problem".in", "r", stdin);
  130. freopen(problem".out", "w", stdout);
  131. }
  132. srand(time(NULL));
  133. cin.tie(0);
  134. cout.tie(0);
  135. ios_base::sync_with_stdio(false);
  136. int t = 1;// cin >> t;
  137. rng(t) solve();
  138. }
  139.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement