#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
#include "biscuits.h"
#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) {
int k = a.size();
ll sum = 0, yf = 0;
for(int i = 0; i < k; i++) {
sum += a[i] << i;
yf += y & (1 << i);
if(sum < x * yf) return false;
}
return true;
}
ll count_tastiness(ll x, vector<ll> a) {
int k = a.size();
cerr << x << '\n';
for(int i = 0; i < k; i++) cerr << a[i] << (i+1==k ? '\n' : ' ');
ll sum = 0;
for(int i = 0; i < k; i++) sum += a[i] << i;
ll ans = 0;
for(int y = 0; y <= sum / x; y++) {
if(check(y, x, a)) ++ans;
}
debug(ans);
return ans;
}
#ifdef local
signed main() {
count_tastiness(3, {5, 2, 1});
count_tastiness(2, {2, 1, 2});
}
#endif // local
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
10 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
256 KB |
Output is correct |
3 |
Correct |
1 ms |
256 KB |
Output is correct |
4 |
Correct |
11 ms |
256 KB |
Output is correct |
5 |
Correct |
2 ms |
256 KB |
Output is correct |
6 |
Correct |
35 ms |
256 KB |
Output is correct |
7 |
Correct |
2 ms |
256 KB |
Output is correct |
8 |
Correct |
34 ms |
256 KB |
Output is correct |
9 |
Correct |
4 ms |
256 KB |
Output is correct |
10 |
Correct |
1 ms |
256 KB |
Output is correct |
11 |
Correct |
1 ms |
256 KB |
Output is correct |
12 |
Incorrect |
35 ms |
256 KB |
Output isn't correct |
13 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
10 ms |
256 KB |
Output is correct |
2 |
Execution timed out |
1082 ms |
256 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1084 ms |
256 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1054 ms |
536 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
10 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
256 KB |
Output is correct |
3 |
Correct |
1 ms |
256 KB |
Output is correct |
4 |
Correct |
11 ms |
256 KB |
Output is correct |
5 |
Correct |
2 ms |
256 KB |
Output is correct |
6 |
Correct |
35 ms |
256 KB |
Output is correct |
7 |
Correct |
2 ms |
256 KB |
Output is correct |
8 |
Correct |
34 ms |
256 KB |
Output is correct |
9 |
Correct |
4 ms |
256 KB |
Output is correct |
10 |
Correct |
1 ms |
256 KB |
Output is correct |
11 |
Correct |
1 ms |
256 KB |
Output is correct |
12 |
Incorrect |
35 ms |
256 KB |
Output isn't correct |
13 |
Halted |
0 ms |
0 KB |
- |