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 auto max_L(S a, T b)
  27. -> typename cLtraits_common_type<S,T>::type{
  28. return (typename cLtraits_common_type<S,T>::type) a >= (typename cLtraits_common_type<S,T>::type) b ? a : b;
  29. }
  30. #define main dummy_main
  31. int main(){
  32. return 0;
  33. }
  34. #undef main
  35. class Solution{
  36. public:
  37. long long minIncrementOperations(vector<int> &A, int k){
  38. int i;
  39. int N = A.size();
  40. static long long dp[1000000];
  41. for(i=(0);i<(3);i++){
  42. dp[i] =max_L(0, k - A[i]);
  43. }
  44. for(i=(3);i<(N);i++){
  45. dp[i] =max_L(0, k - A[i])+min_L(min_L(dp[i-1], dp[i-2]), dp[i-3]);
  46. }
  47. return min_L(min_L(dp[N-1], dp[N-2]), dp[N-3]);
  48. }
  49. }
  50. ;
  51. // cLay version 20231031-1
  52.  
  53. // --- original code ---
  54. // #define main dummy_main
  55. // {}
  56. // #undef main
  57. //
  58. // class Solution {
  59. // public:
  60. // ll minIncrementOperations(VI &A, int k) {
  61. // int N = A.size();
  62. // static ll dp[1d6];
  63. // rep(i,3) dp[i] = max(0, k - A[i]);
  64. // rep(i,3,N) dp[i] = max(0, k - A[i]) + min(dp[i-1], dp[i-2], dp[i-3]);
  65. // return min(dp[N-1], dp[N-2], dp[N-3]);
  66. // }
  67. // };
  68.  
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