# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
434980 | model_code | Distributing Candies (IOI21_candies) | C++17 | 1233 ms | 25556 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
// O((n + q) sqrt(q))
#include "candies.h"
#include <algorithm>
#include <cmath>
#include <vector>
struct Buckets {
int n;
int bucket_size, bucket_cnt;
std::vector<int> vals;
std::vector<long long> mini, maxi, sums;
Buckets(int _n): n(_n) {
bucket_size = sqrt(n);
bucket_cnt = (n + bucket_size - 1) / bucket_size;
vals.assign(n, 0);
mini.assign(bucket_cnt, 0);
maxi.assign(bucket_cnt, 0);
sums.assign(bucket_cnt, 0);
}
void update(int x, int val) {
vals[x] = val;
int bucket = x / bucket_size;
mini[bucket] = maxi[bucket] = sums[bucket] = 0;
for (int i = std::min(n, (bucket + 1) * bucket_size) - 1;
i >= bucket * bucket_size; --i) {
sums[bucket] += vals[i];
# | 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... |