微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Supermarket Queue Codewars kata - UndefinedBehaviorSanitizer:DEADLYSIGNAL ==1==ERROR

如何解决Supermarket Queue Codewars kata - UndefinedBehaviorSanitizer:DEADLYSIGNAL ==1==ERROR

我想解决 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 举报,一经查实,本站将立刻删除。