This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
import java.util.HashMap;
public class biscuits {
long count_tastiness(long x, long[] a) {
HashMap<Long, Long> freq = new HashMap<>();
freq.put(a[0], 1l);
for (int pos = 0; pos < a.length - 1; pos++) {
HashMap<Long, Long> map = new HashMap<>();
for (long y : freq.keySet()) {
long val = a[pos + 1] + y / 2;
Long oldFreq = map.get(val);
map.put(val, (oldFreq != null ? oldFreq.longValue() : 0) + freq.get(y));
if (y >= x) {
val = a[pos + 1] + (y - x) / 2;
oldFreq = map.get(val);
map.put(val, (oldFreq != null ? oldFreq.longValue() : 0) + freq.get(y));
}
}
freq = map;
}
long ans = 0;
for (long y : freq.keySet()) {
ans += freq.get(y) * (y / x + 1);
}
return ans;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |