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