#include <vector>
#include <set>
#include <queue>
#include <algorithm>
using namespace std;
std::vector<int> distribute_candies(std::vector<int> c, std::vector<int> l,std::vector<int> r, std::vector<int> v)
{
int n=c.size();
int q=l.size();
int mi=0;
for(auto i:v)
mi=min(mi,i);
vector<int> ans(n);
deque<pair<int,int>> cp;
for(int i=0;i<n;i++)
cp.push_back({c[i],i});
sort(begin(cp),end(cp));
if(mi>=0)
{
int mis=0;
for(int j=0;j<q;j++)
{
mis+=v[j];
while(cp.size()>0 and (cp.front().first<=(mis)))
{
ans[cp.front().second]=c[cp.front().second];
cp.pop_front();
}
}
while(cp.size()>0)
{
ans[cp.front().second]=mis;
cp.pop_front();
}
}
// else if(sp.size()==1)
// {
// }
else
{
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
95 ms |
13804 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |