fork download
  1. #pragma GCC optimize("Ofast")
  2. #pragma GCC optimize("unroll-loops")
  3. #pragma GCC optimize("inline")
  4. #include<bits/stdc++.h>
  5. using namespace std;
  6. template<class T> struct cLtraits_identity{
  7. using type = T;
  8. }
  9. ;
  10. template<class T> using cLtraits_try_make_signed =
  11. typename conditional<
  12. is_integral<T>::value,
  13. make_signed<T>,
  14. cLtraits_identity<T>
  15. >::type;
  16. template <class S, class T> struct cLtraits_common_type{
  17. using tS = typename cLtraits_try_make_signed<S>::type;
  18. using tT = typename cLtraits_try_make_signed<T>::type;
  19. using type = typename common_type<tS,tT>::type;
  20. }
  21. ;
  22. template<class S, class T> inline auto min_L(S a, T b)
  23. -> typename cLtraits_common_type<S,T>::type{
  24. return (typename cLtraits_common_type<S,T>::type) a <= (typename cLtraits_common_type<S,T>::type) b ? a : b;
  25. }
  26. template<class S, class T> inline S chmax(S &a, T b){
  27. if(a<b){
  28. a=b;
  29. }
  30. return a;
  31. }
  32. #define main dummy_main
  33. int main(){
  34. return 0;
  35. }
  36. #undef main
  37. class Solution{
  38. public:
  39. long long maximumBeauty(vector<int>& A, long long M, int T, int X, int Y){
  40. static long long hist[1000000];
  41. static long long ned[1000000];
  42. long long i;
  43. long long k;
  44. long long m;
  45. long long res;
  46. int N = A.size();
  47. for(i=(0);i<(T+1);i++){
  48. hist[i] = 0;
  49. }
  50. for(i=(0);i<(N);i++){
  51. hist[min_L(A[i], T)]++;
  52. }
  53. k = ned[0] = 0;
  54. for(i=(T+1)-1;i>=(0);i--){
  55. int YGwFZBGH;
  56. for(YGwFZBGH=(0);YGwFZBGH<(hist[i]);YGwFZBGH++){
  57. ned[k+1] = ned[k] + (T - i);
  58. k++;
  59. }
  60. }
  61. k = 0;
  62. while(k+1 <= N && ned[k+1] <= M){
  63. k++;
  64. }
  65. res = k * X;
  66. if(ned[N]==0){
  67. return res;
  68. }
  69. for(i=(1);i<(T);i++){
  70. M -= hist[i-1];
  71. hist[i] += hist[i-1];
  72. hist[i-1] = 0;
  73. if(M < 0){
  74. break;
  75. }
  76. if(k == N){
  77. k--;
  78. }
  79. for(;;){
  80. m =min_L(N-hist[i], k);
  81. if(ned[m] + (T-i) * (k-m) <= M){
  82. break;
  83. }
  84. k--;
  85. }
  86. chmax(res, k * X + i * Y);
  87. }
  88. return res;
  89. }
  90. }
  91. ;
  92. // cLay version 20220312-1
  93.  
  94. // --- original code ---
  95. // #define main dummy_main
  96. // {}
  97. // #undef main
  98. //
  99. // class Solution {
  100. // public:
  101. // ll maximumBeauty(VI& A, ll M, int T, int X, int Y) {
  102. // static ll hist[1d6], ned[1d6];
  103. // ll i, k, m, res; int N = A.size();
  104. //
  105. // rep(i,T+1) hist[i] = 0;
  106. // rep(i,N) hist[min(A[i],T)]++;
  107. //
  108. // k = ned[0] = 0;
  109. // rrep(i,T+1) rep(hist[i]) ned[k+1] = ned[k] + (T - i), k++;
  110. //
  111. // k = 0;
  112. // while(k+1 <= N && ned[k+1] <= M) k++;
  113. // res = k * X;
  114. // if(ned[N]==0) return res;
  115. //
  116. // rep(i,1,T){
  117. // M -= hist[i-1];
  118. // hist[i] += hist[i-1]; hist[i-1] = 0;
  119. // if(M < 0) break;
  120. // if(k == N) k--;
  121. // for(;;){
  122. // m = min(N-hist[i], k);
  123. // if(ned[m] + (T-i) * (k-m) <= M) break;
  124. // k--;
  125. // }
  126. // res >?= k * X + i * Y;
  127. // }
  128. //
  129. // return res;
  130. // }
  131. // };
  132.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/8/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x20): undefined reference to `main'
collect2: error: ld returned 1 exit status
stdout
Standard output is empty