Submission #304065

#TimeUsernameProblemLanguageResultExecution timeMemory
3040652qbingxuanPacking Biscuits (IOI20_biscuits)C++14
Compilation error
0 ms0 KiB
#include "biscuits.h" #include <bits/stdc++.h> #ifdef local #define safe std::cerr<<__PRETTY_FUNCTION__<<" line "<<__LINE__<<" safe\n" #define debug(...) qqbx(#__VA_ARGS__, __VA_ARGS__) template <typename H, typename ...T> void qqbx(const char*s, const H &h, T ...args) { for(; *s && *s != ','; ++s) if(*s != ' ') std::cerr << *s; std::cerr << " = " << h << (sizeof...(T) ? ", " : "\n"); if constexpr (sizeof...(T)) qqbx(++s, args...); } #else #define debug(...) ((void)0) #define safe ((void)0) #endif // local #define pb emplace_back using namespace std; typedef long long ll; const int N = 2500025; bool check(ll y, ll x, vector<ll> a) { ll sum = 0; for(int i = 0; i < k; i++) { sum += a[i]; if(sum < x * (y & ((1<<i+1)-1)) return false; } return true; } ll count_tastiness(ll x, vector<ll> a) { int k = a.size(); ll sum = 0; for(int i = 0; i < k; i++) sum += a[i]; ll ans = 0; for(int y = 0; y <= sum / x; y++) { if(check(y, x, a)) ++ans; } return ans; }

Compilation message (stderr)

biscuits.cpp: In function 'bool check(ll, ll, std::vector<long long int>)':
biscuits.cpp:23:24: error: 'k' was not declared in this scope
   23 |     for(int i = 0; i < k; i++) {
      |                        ^
biscuits.cpp:25:12: warning: init-statement in selection statements only available with '-std=c++17' or '-std=gnu++17'
   25 |         if(sum < x * (y & ((1<<i+1)-1)) return false;
      |            ^~~
biscuits.cpp:25:33: warning: suggest parentheses around '+' inside '<<' [-Wparentheses]
   25 |         if(sum < x * (y & ((1<<i+1)-1)) return false;
      |                                ~^~
biscuits.cpp:25:40: error: expected ';' before 'return'
   25 |         if(sum < x * (y & ((1<<i+1)-1)) return false;
      |                                        ^~~~~~~
      |                                        ;
biscuits.cpp:25:16: warning: statement has no effect [-Wunused-value]
   25 |         if(sum < x * (y & ((1<<i+1)-1)) return false;
      |            ~~~~^~~~~~~~~~~~~~~~~~~~~~~~
biscuits.cpp:26:5: error: expected primary-expression before '}' token
   26 |     }
      |     ^
biscuits.cpp:25:54: error: expected ')' before '}' token
   25 |         if(sum < x * (y & ((1<<i+1)-1)) return false;
      |           ~                                          ^
      |                                                      )
   26 |     }
      |     ~                                                 
biscuits.cpp:26:5: error: expected primary-expression before '}' token
   26 |     }
      |     ^