Submission #436149

#TimeUsernameProblemLanguageResultExecution timeMemory
436149Mohammed_AtalahDistributing Candies (IOI21_candies)C++17
0 / 100
131 ms9772 KiB
#include "candies.h" #include <bits/stdc++.h> #include <vector> using namespace std; std::vector<int> distribute_candies(std::vector<int> c, std::vector<int> l, std::vector<int> r, std::vector<int> v) { long long box = c.size(); vector<long long> partial; partial.resize(box + 1); int e = l.size(); for (int i = 0; i < e; i++) { partial[l[i]] += v[i]; partial[r[i] + 1] -= v[i]; } // cout << partial[3] << endl; vector<int> cum; cum.push_back(partial[0]); for (int i = 1; i < box; i++) { cum.push_back(cum[i - 1] + partial[i]); } vector<int> res; res.resize(box); for (int i = 0; i < box; i++) { // cout << cum[i] << endl; if (cum[i] > 0) { res[i] = min(c[i] * 1, cum[i]); } else { res[i] = 0; } } return res; }
#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...