Submission #1069189

#TimeUsernameProblemLanguageResultExecution timeMemory
1069189BoasDistributing Candies (IOI21_candies)C++17
0 / 100
73 ms12116 KiB
#include "candies.h" #include <bits/stdc++.h> using namespace std; #define int long long typedef vector<int> vi; typedef vector<signed> vi32; typedef vector<bool> vb; typedef vector<vi> vvi; typedef set<int> si; typedef pair<int, int> ii; typedef vector<ii> vii; typedef vector<vii> vvii; #define pb push_back #define loop(x, i) for (int i = 0; i < x; i++) #define ALL(x) begin(x), end(x) #define sz(x) (int)x.size() vi32 distribute_candies(vi32 c, vi32 l, vi32 r, vi32 v) { int n = sz(c); int q = sz(l); int lo = 0, hi = 0, dif = 0; loop(q, i) { if (v[i] > 0) { int d = v[i] + dif; hi += d; // wat als d < 0? dif = 0; lo -= v[i]; lo = max(lo, 0LL); } else { lo -= v[i]; if (lo < 0) dif -= lo; dif += v[i]; if (lo <= -dif) { lo = -dif; } if (lo >= hi) { lo = hi = dif = 0; } } } vi32 s(n); loop(n, i) { if (lo <= c[i] && c[i] <= hi) { s[i] = c[i] + dif; } else if (c[i] > hi) s[i] = hi + dif; else s[i] = lo + dif; if (s[i] < 0) s[i] = 0; if (s[i] > c[i]) s[i] = c[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...