Submission #435511

#TimeUsernameProblemLanguageResultExecution timeMemory
435511grtDistributing Candies (IOI21_candies)C++17
8 / 100
130 ms8900 KiB
#include <bits/stdc++.h> #define ST first #define ND second #define PB push_back using namespace std; using ll = long long; using pi = pair<int,int>; using vi = vector<int>; int n, q; vector<int> distribute_candies(vi c, vi l, vi r, vi v) { n = (int)c.size(); q = (int)l.size(); vector<ll> ans(n); for(int i = 0; i < q; ++i) { ans[l[i]] += v[i]; if(r[i] + 1 < n) ans[r[i] + 1] -= v[i]; } for(int i = 1; i < n; ++i) { ans[i] += ans[i - 1]; } vi ans2(n); for(int i = 0; i < n; ++i) { ans2[i] = min(ans[i], (ll)c[i]); } return ans2; } //int main() { //ios_base::sync_with_stdio(0); //cin.tie(0); //vector<ll> w = distribute_candies({10, 15, 13}, {0, 0}, {2, 1}, {20, -11}); //vector<ll>w = distribute_candies({10, 15, 13}, {0, 0}, {2, 1}, {8, 4}); //for(int x : w) { //cout << x << " "; //} //}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...