#include "candies.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define F first
#define S second
#define pb push_back
#define sz(x) (ll)x.size()
typedef vector <int> vl;
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;
}
vl distribute_candies(vl ccc, vl lll, vl rrr, vl vvv) {
vi c(sz(ccc)), l(sz(lll)), r(sz(lll)), v(sz(lll));
for (ll i =0; i<sz(ccc); i++){
c[i] = ccc[i];
}
for (ll i =0; i<sz(lll); i++){
l[i] = lll[i];
r[i] = rrr[i];
v[i] = vvv[i];
}
ll n = sz(c);
ll q = sz(l);
vi ans(n);
vi s(n+1,0);
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);
}
vl final_ans(sz(ans));
for (ll i= 0; i<sz(ans); i++){
final_ans[i] = ans[i];
}
return final_ans;
}
/*
4
20 20 20 20
3
0 2 10
0 1 5
1 3 15
3
10 15 13
2
0 2 20
0 1 -11
*/
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
73 ms |
21688 KB |
Output is correct |
2 |
Correct |
68 ms |
20720 KB |
Output is correct |
3 |
Correct |
71 ms |
20560 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |