# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
617934 | 2022-08-01T17:12:09 Z | sokratisi | Distributing Candies (IOI21_candies) | C++17 | 149 ms | 14752 KB |
#include "candies.h" #include <set> #include <vector> #include <algorithm> using namespace std; vector<int> distribute_candies(vector<int> c, vector<int> l, vector<int> r, vector<int> v) { int n = c.size(); vector<int> s(n, 0); int q = l.size(); vector<pair<pair<int, int>, int>> edges; for (int i = 0; i < q; i++) { edges.push_back({{l[i], 1}, v[i]}); edges.push_back({{r[i] + 1, 0}, v[i]}); } sort(edges.begin(), edges.end()); int pos = 0; int add = 0; for (int i = 0; i < n; i++) { while (pos < edges.size() && edges[pos].first.first == i) { if (edges[pos].first.second) { add += edges[pos].second; } else { add -= edges[pos].second; } pos++; } s[i] = min(c[i], add); } return s; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 212 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 149 ms | 14752 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 212 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 212 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 212 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |