# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1053321 | 2024-08-11T10:28:20 Z | tolbi | Distributing Candies (IOI21_candies) | C++17 | 75 ms | 13652 KB |
#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; } } for (int i = 0; i < n; ++i) { if (ans[i]==-1) ans[i]=mav; } return normalize(ans); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Incorrect | 0 ms | 348 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 75 ms | 13652 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 348 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 348 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Incorrect | 0 ms | 348 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |