Submission #440387

#TimeUsernameProblemLanguageResultExecution timeMemory
440387ACE_Distributing Candies (IOI21_candies)C++17
3 / 100
129 ms10096 KiB
#include "candies.h" #include<bits/stdc++.h> using namespace std; int p[200005]; #include <vector> std::vector<int> distribute_candies(std::vector<int> c, std::vector<int> l, std::vector<int> r, std::vector<int> v) { int n = c.size(); vector<int>ans(n); int q = l.size(); if (n <= 2000 && q <= 2000) { // subtask #1 for (int i = 0; i <= q; i++) { for (int j = l[i]; j <= r[i]; j++) { ans[j] = min(c[j], max(0, ans[j] + v[i])); } } return ans; } else { for (int i = 0; i <= q; i++) { p[l[i]] += v[i]; p[r[i] + 1] -= v[i]; } for (int i = 0; i <= q; i++) { if (i) p[i] += p[i - 1]; ans[i] = min(c[i], p[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...