fork download
  1. #include <bits/stdc++.h>
  2.  
  3. constexpr int MAXB = 1e5;
  4.  
  5. int sushi(int, int const B, std::vector<int> const A) {
  6. assert(B <= MAXB);
  7.  
  8. if (B == 0) return 0;
  9.  
  10. std::bitset<MAXB + 1> K(1);
  11. int R{1};
  12.  
  13. for (;;) {
  14. auto K2 = K;
  15. for (auto const &a : A) K2 |= K2 << (a * R);
  16. if (K2.test(B)) break;
  17. R *= 2;
  18. K = K2;
  19. if (R > B) return -1;
  20. }
  21.  
  22. for (int k{R / 2}; k; k /= 2) {
  23. auto K2 = K;
  24. for (auto const &a : A) K2 |= K2 << (a * k);
  25. if (!K2.test(B)) {
  26. R |= k;
  27. K = K2;
  28. }
  29. }
  30.  
  31. return R;
  32. }
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