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 chmin(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. int minimumSum(vector<int> &A){
  40. int i;
  41. int N = A.size();
  42. static long long x[1000000];
  43. static long long y[1000000];
  44. long long res = 4611686016279904256LL;
  45. x[0] = A[0];
  46. y[N-1] = A[N-1];
  47. for(i=(1);i<(N);i++){
  48. x[i] =min_L(x[i-1], A[i]);
  49. }
  50. for(i=(N-1)-1;i>=(0);i--){
  51. y[i] =min_L(y[i+1], A[i]);
  52. }
  53. for(i=(1);i<(N-1);i++){
  54. if(x[i-1] < A[i] && A[i] > y[i+1]){
  55. chmin(res, x[i-1] + A[i] + y[i+1]);
  56. }
  57. }
  58. if(res==4611686016279904256LL){
  59. return -1;
  60. }
  61. else{
  62. return res;
  63. }
  64. }
  65. }
  66. ;
  67. // cLay version 20231031-1
  68.  
  69. // --- original code ---
  70. // #define main dummy_main
  71. // {}
  72. // #undef main
  73. //
  74. // class Solution {
  75. // public:
  76. // int minimumSum(VI &A) {
  77. // int i, N = A.size();
  78. // static ll x[1d6], y[1d6];
  79. // ll res = ll_inf;
  80. //
  81. // x[0] = A[0]; y[N-1] = A[N-1];
  82. // rep(i,1,N) x[i] = min(x[i-1], A[i]);
  83. // rrep(i,N-1) y[i] = min(y[i+1], A[i]);
  84. //
  85. // rep(i,1,N-1) if(x[i-1] < A[i] && A[i] > y[i+1]) res <?= x[i-1] + A[i] + y[i+1];
  86. // return if[res==ll_inf, -1, res];
  87. // }
  88. // };
  89.  
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