Submission #574272

#TimeUsernameProblemLanguageResultExecution timeMemory
574272wjajjsasqqDistributing Candies (IOI21_candies)C++17
3 / 100
5083 ms8124 KiB
#include "candies.h" #include <cstdio> #pragma GCC optimize("Ofast,unroll-loops") #pragma GCC target("avx2,tune=native") const int N = 200000; int n, a[N], c[N]; std::vector<int> distribute_candies(std::vector<int> c_, std::vector<int> l, std::vector<int> r, std::vector<int> v) { n = (int)c_.size(); for (int i = 0; i < n; ++i) c[i] = c_[i]; for (int i = 0; i < (int)l.size(); ++i) { int ll = l[i], rr = r[i] + 1, d = v[i]; for (int j = ll; j < rr; ++j) a[j] += d; if (d > 0) { for (int j = ll; j < rr; ++j) a[j] = a[j] < c[j] ? a[j] : c[j]; } else { for (int j = ll; j < rr; ++j) a[j] = a[j] < 0 ? 0 : a[j]; } } std::vector<int> ans(n); for (int i = 0; i < n; ++i) ans[i] = a[i]; return ans; }
#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...