fork download
  1. #pragma GCC optimize ("Ofast")
  2. #include<bits/stdc++.h>
  3. using namespace std;
  4. template<class S, class T> inline S max_L(S a,T b){
  5. return a>=b?a:b;
  6. }
  7. template<class S, class T> inline S chmax(S &a, T b){
  8. if(a<b){
  9. a=b;
  10. }
  11. return a;
  12. }
  13. #define main dummy_main
  14. int main(){
  15. return 0;
  16. }
  17. #undef main
  18. class Solution{
  19. public:
  20. int maximumSum(vector<int>& A){
  21. int i;
  22. int mx;
  23. int N;
  24. int lf[100000];
  25. int rg[100000];
  26. int res = 0;
  27. N = A.size();
  28. {
  29. int Lj4PdHRW;
  30. int KL2GvlyY;
  31. if(N==0){
  32. KL2GvlyY = 0;
  33. }
  34. else{
  35. KL2GvlyY = A[0];
  36. for(Lj4PdHRW=(1);Lj4PdHRW<(N);Lj4PdHRW++){
  37. KL2GvlyY = max_L(KL2GvlyY, A[Lj4PdHRW]);
  38. }
  39. }
  40. mx =KL2GvlyY;
  41. }
  42. if(mx <= 0){
  43. return mx;
  44. }
  45. lf[0] = 0;
  46. for(i=(1);i<(N);i++){
  47. lf[i] =max_L(0, lf[i-1]+A[i-1]);
  48. }
  49. rg[N-1] = 0;
  50. for(i=N-2;i>=0;i--){
  51. rg[i] =max_L(0, rg[i+1]+A[i+1]);
  52. }
  53. for(i=0;i<(N);i++){
  54. chmax(res, max_L(0, A[i])+ lf[i] + rg[i]);
  55. }
  56. return res;
  57. }
  58. }
  59. ;
  60. // cLay varsion 20190914-1
  61.  
  62. // --- original code ---
  63. // #define main dummy_main
  64. // {}
  65. // #undef main
  66. //
  67. // class Solution {
  68. // public:
  69. // int maximumSum(vector<int>& A) {
  70. // int i, mx, N;
  71. // int lf[1d5], rg[1d5];
  72. // int res = 0;
  73. //
  74. // N = A.size();
  75. //
  76. // mx = max(A(N));
  77. // if(mx <= 0) return mx;
  78. //
  79. // lf[0] = 0;
  80. // rep(i,1,N) lf[i] = max(0, lf[i-1]+A[i-1]);
  81. // rg[N-1] = 0;
  82. // for(i=N-2;i>=0;i--) rg[i] = max(0, rg[i+1]+A[i+1]);
  83. //
  84. // rep(i,N) res >?= max(0, A[i]) + lf[i] + rg[i];
  85. // return res;
  86. // }
  87. // };
  88.  
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