Submission #435507

#TimeUsernameProblemLanguageResultExecution timeMemory
435507grtDistributing Candies (IOI21_candies)C++17
0 / 100
102 ms8032 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<ll> 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]; } for(int i = 0; i < n; ++i) { ans[i] = min(ans[i], (ll)c[i]); } return ans; } //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}); //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...