Submission #828715

#TimeUsernameProblemLanguageResultExecution timeMemory
828715fatemetmhrDistributing Candies (IOI21_candies)C++17
38 / 100
5026 ms11700 KiB
//#pragma GCC optimize ("O3") #pragma GCC target("avx2") #pragma GCC optimize("unroll-loops,O3") #include "candies.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; #define debug(x) cerr << "(" << (#x) << "): " << (x) << endl; #define all(x) x.begin(), x.end() #define MAX(x, y) ((x) > (y) ? (x) : (y)) #define MIN(x, y) ((x) < (y) ? (x) : (y)) #define fi first #define se second #define pb push_back #define mp make_pair const int ss = 1500; const int maxn5 = 2e5 + 10; int ret[maxn5], c[maxn5]; int L[maxn5], R[maxn5], V[maxn5]; std::vector<int> distribute_candies(std::vector<int> C, std::vector<int> LL, std::vector<int> RR, std::vector<int> VV) { int n = C.size(), q = LL.size(); for(int i = 0; i < n; i++) c[i] = C[i]; for(int i = 0; i < q; i++){ L[i] = LL[i]; R[i] = RR[i]; V[i] = VV[i]; } for(int tt = 0; tt < n; tt += ss){ for(int i = 0; i < q; i++){ int l = MAX(L[i], tt), r = MIN(R[i] + 1, MIN(tt + ss, n)), v = V[i]; if(v > 0){ for(int i = l; i < r; i++){ ret[i] = MIN(c[i], ret[i] + v); } } else{ for(int i = l; i < r; i++){ ret[i] = MAX(0, ret[i] + v); } } } } std::vector<int> s; for(int i = 0; i < n; i++) s.pb(ret[i]); return s; }
#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...