#include "candies.h"
#include<bits/stdc++.h>
using namespace std;
vector<int> distribute_candies(vector<int> c, vector<int> l,vector<int> r, vector<int> v) {
cout << "PIAPSJD" << endl;
long long n = c.size(),q = v.size();
vector<long long> su(q+1);
vector<pair<long long,long long>> sm(q+2);
vector<pair<long long,long long>> big(q+2);
sm[q] = {0,q};
big[q] = {0,q};
sm[q+1] = {0,q+1};
big[q+1] = {0,q+1};
for(long long i = q-1; i >= 0; i--) {
su[i] = v[i];
su[i]+=su[i+1];
if(su[i] < sm[i+1].first) {
sm[i] = {su[i],i};
}
else {
sm[i] = sm[i+1];
}
if(su[i] > big[i+1].first) {
big[i] = {su[i],i};
}
else {
big[i] = big[i+1];
}
}
vector<pair<long long,long long>> haha(n);
for(long long i = 0; i < n; i++) {
haha.push_back({c[i],i});
}
sort(haha.begin(),haha.end());
reverse(haha.begin(),haha.end());
long long p = -1;
bool yeah = true;
vector<int> ans(n);
for(long long i = 0; i < n; i++) {
while(p+1 < q) {
if(yeah) {
if(su[p+1]-big[p+2].first <= 0) {
p = big[p+2].second-1;
yeah = true;
}
else if(su[p+1]-sm[p+2].first >= haha[i].first) {
p = sm[p+2].second-1;
yeah = false;
}
else {
break;
}
}
else {
if(su[p+1]-big[p+2].first <= -haha[i].first) {
p = big[p+2].second-1;
yeah = true;
}
else if(su[p+1]-sm[p+2].first >= 0){
p = sm[p+2].second-1;
yeah = false;
}
else {
break;
}
}
}
if(yeah) {
ans[haha[i].second] = su[p+1];
}
else {
ans[haha[i].second] = haha[i].first+su[p+1];
}
}
return ans;
}
# |
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 |
Incorrect |
107 ms |
26396 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 |
Incorrect |
0 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 |
- |