# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
599150 | lcj | Distributing Candies (IOI21_candies) | C++17 | 114 ms | 12980 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.
#include <bits/stdc++.h>
#include "candies.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
#define LSOne(s) ((s) & -(s))
struct Fenwick {
vector<ll> ft;
Fenwick(int n) : ft(n+1, 0) {}
ll query(int i) {
ll su = 0;
for (; i > 0; i -= LSOne(i)) {
su += ft[i];
}
return su;
}
void update(int i, ll dv) {
for (; i < ft.size(); i += LSOne(i))
{
ft[i] += dv;
}
}
};
vector<int> distribute_candies(vector<int> c, vector<int> l, vector<int> r, vector<int> v) {
int n = c.size();
Fenwick ft(n);
for (int i = 0; i < l.size(); i++)
{
ft.update(r[i]+2, -v[i]);
ft.update(l[i]+1, v[i]);
}
std::vector<int> s(n);
for (int i = 0; i < n; i++)
{
s[i] = min(ft.query(i+1), (ll)c[i]);
}
return s;
}
Compilation message (stderr)
# | 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... |