# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1058408 | 2024-08-14T09:52:03 Z | vjudge1 | Distributing Candies (IOI21_candies) | C++17 | 0 ms | 0 KB |
#include "candies.h" #include <vector> #include <bits/stdc++.h> using vi = vector<int>; vi distribute_candies(vi c, vi l, vi r, vi v) { int n = c.size(), q = l.size(); bool all_poz = true; for(auto it : v) if(it < 0) all_poz = false; if(n <= 2000 && q <= 2000) { vi A(n, 0); for(int i = 0; i < q; ++i) { for(int j = l[i]; j <= r[i]; ++j) { A[j] += v[i]; A[j] = max(A[j], 0); A[j] = min(A[j], c[j]); } } return A; } }