fork download
  1. #pragma GCC optimize ("Ofast")
  2. #include<bits/stdc++.h>
  3. using namespace std;
  4. #define main dummy_main
  5. int main(){
  6. return 0;
  7. }
  8. #undef main
  9. class Solution{
  10. public:
  11. int maxOperations(vector<int>& A, int K){
  12. int res = 0;
  13. int N = A.size();
  14. int x = 0;
  15. int y = N-1;
  16. sort(A.begin(), A.end());
  17. while(x < y){
  18. if(A[x] + A[y] == K){
  19. res++;
  20. x++;
  21. y--;
  22. continue;
  23. }
  24. if(A[x] + A[y] < K){
  25. x++;
  26. }
  27. else{
  28. y--;
  29. }
  30. }
  31. return res;
  32. }
  33. }
  34. ;
  35. // cLay version 20201206-1
  36.  
  37. // --- original code ---
  38. // #define main dummy_main
  39. // {}
  40. // #undef main
  41. //
  42. // class Solution {
  43. // public:
  44. // int maxOperations(vector<int>& A, int K) {
  45. // int res = 0, N = A.size(), x = 0, y = N-1;
  46. // sort(A.begin(), A.end());
  47. // while(x < y){
  48. // if(A[x] + A[y] == K) res++, x++, y--, continue;
  49. // if[A[x] + A[y] < K, x++, y--];
  50. // }
  51. // return res;
  52. // }
  53. // };
  54.  
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