Closed emmaroberts911 closed 3 years ago
emmaroberts
During the 3rd problem of contest 323 1792. Maximum Average Pass Ratio, my 2nd submission with Python got TLE. But when I tried this solution after the contest, it got accepted 100% of the time.
Please help re-judge. Thanks in advance!
Submission ID: 467468857 Submission Link: https://leetcode.com/contest/weekly-contest-232/submissions/detail/467468857/
import heapq class Class: def __init__(self, _pass, total): self._pass = _pass self._total = total self._pass_rate = _pass / total self._growth_rate = (self._pass + 1) / (self._total + 1) - self._pass_rate def __repr__(self): return f'<{self._pass}/{self._total}>' @property def growth_rate(self): return self._growth_rate @property def pass_rate(self): return self._pass_rate def add_pass(self): self._pass += 1 self._total += 1 self._pass_rate = self._pass / self._total self._growth_rate = (self._pass + 1) / (self._total + 1) - self._pass_rate def __lt__(self, other): return self.growth_rate > other.growth_rate class Solution: def maxAverageRatio(self, classes: List[List[int]], extraStudents: int) -> float: classObjs = [Class(p, t) for p, t in classes] heapq.heapify(classObjs) while extraStudents > 0: minClass = heapq.heappop(classObjs) minClass.add_pass() heapq.heappush(classObjs, minClass) extraStudents -= 1 return sum(c.pass_rate for c in classObjs) / len(classObjs)
Python3
The above solution should be AC. However, during the contest it was TLE.
AC:
Tried multiple times after contest, all AC:
Same exact code, got TLE during contest:
fixed. thanks!
Your LeetCode username
emmaroberts
Category of the bug
Description of the bug
During the 3rd problem of contest 323 1792. Maximum Average Pass Ratio, my 2nd submission with Python got TLE. But when I tried this solution after the contest, it got accepted 100% of the time.
Please help re-judge. Thanks in advance!
Submission ID: 467468857 Submission Link: https://leetcode.com/contest/weekly-contest-232/submissions/detail/467468857/
Code you used for Submit/Run operation
Language used for code
Python3
Expected behavior
The above solution should be AC. However, during the contest it was TLE.
Screenshots
AC:
Tried multiple times after contest, all AC:
Same exact code, got TLE during contest:
Additional context