Submission #814133

#TimeUsernameProblemLanguageResultExecution timeMemory
814133LittleCubeDistributing Candies (IOI21_candies)C++17
11 / 100
97 ms8256 KiB
#include "candies.h" #include <bits/stdc++.h> #define ll long long using namespace std; vector<int> distribute_candies(vector<int> c, vector<int> l, vector<int> r, vector<int> v) { int n = c.size(), q = l.size(); if (q <= 2000) { vector<int> s(n, 0); for (int i = 0; i < q; i++) { for (int j = l[i]; j <= r[i]; j++) s[j] = max(0, min(c[j], s[j] + v[i])); } return s; } else { vector<ll> s(n + 1); 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++) c[i] = min((ll)c[i], s[i]); return c; } return {}; }
#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...