# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
522694 | InternetPerson10 | Distributing Candies (IOI21_candies) | C++17 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "candies.h"
#include <vector>
using namespace std;
vector<int> distribute_candies(vector<int> c, vector<int> l, vector<int> r, vector<int> v) {
int n = c.size();
vector<ll> s(n+1);
bool subtask2 = true, subtask3 = true, subtask4 = true;
for(int i = 0; i < n; i++) {
if(v[j] < 0) subtask2 = false;
if(i > 0 && c[i] != c[i-1]) subtask3 = false;
if(r[i] - l[i] != n-1) subtask4 = false;
}
if(n <= 2000 && q <= 2000) { // Subtask 1
for(int i = 0; i < q; i++) {
for(int j = l[i], j <= r[i], j++) {
s[j] += v[j];
s[j] = max(s[j], 0);
s[j] = min(s[j], c[j]);
}
}
}
else if(subtask2) {
for(int i = 0; i < q; i++) {
s[l[i]] += v[i];
s[r[i]+1] -= v[i];
}
for(int i = 1; i < n; i++) {
s[i] += s[i-1];
}
for(int i = 0; i < n; i++) {
s[i] = min(s[i], c[i]);
}
}
else if(subtask3) {
}
else if(subtask4) {
}
else {
}
vector<int> sInt(n);
for(int i = 0; i < n; i++) sInt[i] = s[i];
return sInt;
}