Submission #827174

#TimeUsernameProblemLanguageResultExecution timeMemory
827174NothingXDDistributing Candies (IOI21_candies)C++17
3 / 100
5055 ms10224 KiB
#include "candies.h" #include <bits/stdc++.h> #pragma GCC optimize("unroll-loops") #pragma GCC optimize("O3") #pragma GCC target("avx") using namespace std; typedef long long ll; typedef pair<int,int> pii; typedef pair<ll,ll> pll; void debug_out(){cerr << endl;} template<typename Head, typename... Tail> void debug_out(Head H, Tail... T){ cerr << H << ' '; debug_out(T...); } #define debug(...) cerr << "(" << #__VA_ARGS__ << "): ", debug_out(__VA_ARGS__) #define F first #define S second #define all(x) x.begin(), x.end() #define MP(x, y) make_pair(x, y) const int maxn = 2e5 + 10; int n, q, a[maxn], c[maxn]; vector<int> distribute_candies(vector<int> C, vector<int> L, vector<int> R, vector<int> V) { n = C.size(); for (int i = 0; i < n; i++){ c[i] = C[i]; } q = L.size(); for (int i = 0; i < q; i++){ if (V[i] > 0){ for (int j = L[i]; j <= R[i]; j++){ a[j] = (a[j]+V[i] >= c[j]? c[j]: a[j]+V[i]); // debug(j, a[j]); } } if (V[i] < 0){ for (int j = L[i]; j <= R[i]; j++){ a[j] = (a[j]+V[i] <= 0? 0: a[j]+V[i]); // debug(j, a[j]); } } } vector<int> ans; for (int i = 0; i < n; i++){ ans.push_back(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...