问题描述
我想解决 codewars 中的 Supermarket Queue 问题,但我一直收到错误
test: malloc.c:2401: sysmalloc: Assertion `(old_top == initial_top (av) && old_size == 0) || ((unsigned long) (old_size) >= MINSIZE && prev_inuse (old_top) && ((unsigned long) old_end & (pagesize - 1)) == 0)' 失败。 UndefinedBehaviorSanitizer:DEADLYSIGNAL ==1==错误
谁能告诉我为什么?
问题描述链接: https://www.codewars.com/kata/57b06f90e298a7b53d000a86
long queueTime(std::vector<int> customers,int n) {
std::vector<int> tills(n,0);
int aux = 0;
int l = 0;
for (unsigned int i = 0; i < customers.size(); i++) {
if (l == n)
l = 0;
tills[l] += customers[i];
L++;
for (int j = 0; j < n; j++) {
for (int k = j + 1; k < n; k++ ){
if (tills[i] > tills[j]) {
aux = tills[j];
tills[j] = tills[i];
tills[i] = aux;
}
}
}
}
int max = tills[0];
for (int i = 0; i < n; i++) {
if (max < tills[i])
max = tills[i];
}
return max;
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)