Submission #1081858

#TimeUsernameProblemLanguageResultExecution timeMemory
1081858ALeonidouDistributing Candies (IOI21_candies)C++17
0 / 100
69 ms12884 KiB
#include "candies.h" #include <bits/stdc++.h> using namespace std; #define ll int #define F first #define S second #define pb push_back #define sz(x) (ll)x.size() typedef vector <ll> vi; typedef pair <ll,ll> ii; typedef vector <ii> vii; #define dbg(x) cout<<#x<<": "<<x<<endl; #define dbg2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl; #define dbg3(x,y,z) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<" "<<#z<<": "<<z<<endl; void printVct(vi &v){ for (ll i =0; i<sz(v); i++){ cout<<v[i]<<" "; } cout<<endl; } vi distribute_candies(vi c, vi l, vi r, vi v) { ll n = sz(c); ll q = sz(l); vi ans(n); vi s(n+1); for (ll i =0; i<q; i++){ s[l[i]] += v[i]; s[r[i]+1] -= v[i]; } ll p = 0; for (ll i =0; i<n; i++){ p += s[i]; ans[i] = min(c[i], p); } return ans; } /* 3 40 15 13 2 0 2 20 0 1 11 3 10 15 13 2 0 2 20 0 1 -11 */
#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...