# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
975063 | 2024-05-04T11:18:13 Z | pransh_8 | 사탕 분배 (IOI21_candies) | C++17 | 0 ms | 0 KB |
//pransh_8 #include <bits/stdc++.h> #include "candies.h" using namespace std; //Macros: #define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL) #define all(a) a.begin(),a.end() #define ff first #define ss second #define int long long #define inf 9223372036854775807 #define pii pair<int, int> #define vtr vector #define pob pop_back #define pb push_back #define endl "\n" #define tab "\t" #define spc ' ' #define typ typename #define printif(condition,str1,str2) cout<<((condition)?str1:str2) << endl #define FOR(i, a, n) for(int i=a;i<n;++i) #define FORR(i, a, n) for(int i=a;i>=n;--i) /*------------------------------Code-Begins----------------------------------*/ vector<int> distribute_candies(vector<int> c, vtr<int> l, vtr<int> r, vtr<int> v) { int n = c.size(), q = l.size(); vtr<int> ans(n); FOR(i,0,q) { FOR(k,l[i]-1,r[i]) { if (v[i]>0) ans[k]=min(c[k],ans[k]+v[i]); else ans[k]=max(0ll,ans[k]+v[i]); } } return ans; }