#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
using namespace std;
vector<long long> trans(const vector<long long>& a, long long sub) {
vector<long long> na = a;
na.pop_back();
if (a.back() - sub > 1) {
long long val = (a.back() - sub) / 2;
if (na.size() == 0) na.push_back(val);
else na.back() += val;
}
return na;
}
long long solve(long long x, vector<long long> a) {
if (a.size() == 0) return 1;
long long ret = 0;
if (a.back() >= x) {
ret += solve(x, trans(a, x));
}
ret += solve(x, trans(a, 0));
return ret;
}
long long count_tastiness(long long x, vector<long long> a) {
reverse(a.begin(), a.end());
return solve(x, a);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
10 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
256 KB |
Output is correct |
4 |
Correct |
21 ms |
256 KB |
Output is correct |
5 |
Correct |
5 ms |
256 KB |
Output is correct |
6 |
Correct |
53 ms |
256 KB |
Output is correct |
7 |
Correct |
3 ms |
256 KB |
Output is correct |
8 |
Correct |
53 ms |
256 KB |
Output is correct |
9 |
Correct |
7 ms |
256 KB |
Output is correct |
10 |
Correct |
0 ms |
256 KB |
Output is correct |
11 |
Correct |
0 ms |
256 KB |
Output is correct |
12 |
Correct |
272 ms |
376 KB |
Output is correct |
13 |
Correct |
118 ms |
256 KB |
Output is correct |
14 |
Correct |
11 ms |
256 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
10 ms |
384 KB |
Output is correct |
2 |
Execution timed out |
1095 ms |
256 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1097 ms |
256 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1088 ms |
384 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
10 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
256 KB |
Output is correct |
4 |
Correct |
21 ms |
256 KB |
Output is correct |
5 |
Correct |
5 ms |
256 KB |
Output is correct |
6 |
Correct |
53 ms |
256 KB |
Output is correct |
7 |
Correct |
3 ms |
256 KB |
Output is correct |
8 |
Correct |
53 ms |
256 KB |
Output is correct |
9 |
Correct |
7 ms |
256 KB |
Output is correct |
10 |
Correct |
0 ms |
256 KB |
Output is correct |
11 |
Correct |
0 ms |
256 KB |
Output is correct |
12 |
Correct |
272 ms |
376 KB |
Output is correct |
13 |
Correct |
118 ms |
256 KB |
Output is correct |
14 |
Correct |
11 ms |
256 KB |
Output is correct |
15 |
Correct |
10 ms |
384 KB |
Output is correct |
16 |
Execution timed out |
1095 ms |
256 KB |
Time limit exceeded |
17 |
Halted |
0 ms |
0 KB |
- |