# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1053327 | tolbi | Distributing Candies (IOI21_candies) | C++17 | 5095 ms | 13744 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 "candies.h"
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define tol(bi) ((1LL)<<((int)(bi)))
template<typename T> vector<int32_t> normalize(vector<T> v){
vector<int32_t> ret(v.size());
for (int i = 0; i < v.size(); ++i)
{
ret[i]=v[i];
}
return ret;
}
vector<int32_t> distribute_candies(vector<int32_t> c, vector<int32_t> l, vector<int32_t> r, vector<int32_t> v) {
int n = c.size();
pair<int,int> pn[n];
for (int i = 0; i < n; i++){
pn[i]={c[i],i};
}
sort(pn,pn+n);
int ind = 0;
int mav = 0;
int miv = 0;
vector<int> ans(n,-1);
for (int i = l.size()-1; i >= 0; i--){
int val = v[i];
if (val<0){
miv-=val;
}
else {
mav+=val;
}
while (ind<n){
if (mav+miv>=pn[ind].first){
if (val<0) ans[pn[ind].second]=mav;
else ans[pn[ind].second]=pn[ind].first-miv;
ind++;
}
else break;
}
}
while (ind<n){
ans[pn[ind].second]=mav;
}
return normalize(ans);
}
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... |