#include "biscuits.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
const int N = 3e5+5;
const int MOD = 1e9+7;
const ll INF = 1e18+5;
#ifdef dremix
#define p2(x,y) cerr<<#x<<", "<<#y<<" = "<<x<<", "<<y<<endl;
#define ppv(x) cerr<<#x<<" = {";for(auto v : x)cerr<<v.F<<"-"<<v.S<<", ";cerr<<"}"<<endl;
#define pv(x) cerr<<#x<<" = {";for(auto v : x)cerr<<v<<", ";cerr<<endl;
#else
#define p2(x,y) {}
#define ppv(x) {}
#define pv(x) {}
#endif
long long count_tastiness(long long x, std::vector<long long> a) {
int n = a.size();
ll sum = 0;
ll i;
for(i=0;i<n;i++){
sum += (1ll<<i) * a[i];
}
ll ub = sum/x;
ll ret = 1;
for(i=1;i<=ub;i++){
vector<ll> curr = a;
bool ok = 1;
for(ll j=n-1;j>=0;j--){
if(((1ll<<j)&i)==false){
continue;
}
ll k = j;
ll need = x;
while(need > 0 && k >= 0){
ll temp = min(need,curr[k]);
need -= temp;
curr[k] -= temp;
need *= 2;
k--;
}
if(need > 0){
ok = 0;
}
}
p2(i,ok)
ret += ok;
}
return ret;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
296 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
4 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
17 ms |
296 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
16 ms |
272 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
20 ms |
212 KB |
Output is correct |
13 |
Correct |
9 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
300 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
292 KB |
Output is correct |
2 |
Execution timed out |
1068 ms |
212 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1074 ms |
212 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1073 ms |
340 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
296 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
4 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
17 ms |
296 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
16 ms |
272 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
20 ms |
212 KB |
Output is correct |
13 |
Correct |
9 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
300 KB |
Output is correct |
15 |
Correct |
7 ms |
292 KB |
Output is correct |
16 |
Execution timed out |
1068 ms |
212 KB |
Time limit exceeded |
17 |
Halted |
0 ms |
0 KB |
- |