Submission #601994

#TimeUsernameProblemLanguageResultExecution timeMemory
601994snokesDistributing Candies (IOI21_candies)C++17
0 / 100
98 ms8040 KiB
#include <bits/stdc++.h> #include "candies.h" using namespace std; #ifdef LOCAL void print() {cerr << "]" << endl;} template<typename Head, typename... Tail> void print(Head H, Tail... T) {cerr << H; if(sizeof...(T)) cerr << ", "; print(T...);} template<typename T> ostream& operator << (ostream& os, vector<T> v) {os << "["; string sep = ""; for(auto& x : v) {os << sep << x; sep = ", ";} return os << "]";} template<typename A, typename B> ostream& operator << (ostream& os, pair<A, B> p) {return os << "(" << p.first << ", " << p.second << ")";} #define dbg(x...) cerr << "[" << #x << ": ", print(x); #else #define dbg(x...) 42; #endif // LOCAL #define vt vector #define sz(x) int((x).size()) #define ll long long #define pb push_back #define all(x) (x).begin(), (x).end() vt<int> distribute_candies(vt<int> C, vt<int> L, vt<int> R, vt<int> v) { int N = sz(C); int Q = sz(L); vt<int> ans(N), dif(N + 1); for(int i = 0; i < Q; i++) { assert(v[i] > 0); dif[L[i]] += v[i]; dif[R[i] + 1] -= v[i]; } int cur = 0; for(int i = 0; i < N; i++) { cur += dif[i]; ans[i] = min(cur, C[i]); } return ans; } /* int main() { int N; cin >> N; vt<int> C(N); for(int i = 0; i < N; i++) cin >> C[i]; int Q; cin >> Q; vt<int> L(Q), R(Q), V(Q); for(int i = 0; i < Q; i++) cin >> L[i] >> R[i] >> V[i]; for(int x : distribute_candies(C, L, R, V)) cout << x << " "; cout << "\n"; } */ /* 3 3 3 5 3 0 0 1 1 2 3 0 2 1 */
#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...