def tryexcept_GlobalFunc(strParam): try: raise DummyError("An error occured.") print(globalVar) global globalVar except (NameError): int_localVar = system.maxsize() except: os.getenv(strParam) globalVar = True
def maxProfit2(prices : List[int]) -> int: # sys.maxsize() 함수를 통해 시스템의 최대( - 최소) 값을 지정 해 둔다. profit = 0 min_price = sys.maxsize() # 최소값과 최대값을 계속 갱신 for price in prices: min_price = min(min_price, price) profit = max(profit, price - min_price) return profit
def eggDrop(n, k): max_size = sys.maxsize() dp = [[max_size] * (k + 1) for i in range(n + 1)] for i in range(1, n + 1): dp[i][0] = 0 dp[i][1] = 1 for j in range(1, k + 1): dp[1][j] = j for i in range(2, n + 1): for j in range(2, k + 1): for x in range(1, j + 1): res = 1 + max(dp[i - 1][x - 1], dp[i][j - x]) dp[i][j] = min(res, dp[i][j]) return dp[n][k]
def dijkstra(N,start,graph): visit = [False] * N dist = [sys.maxsize()] * N dist[start] = 0 pq = [] heapq.heappush(pq, [0,start]) while pq: minValue, index = heapq.heappop(pq) visit[index] = True for edge in graph[start]:
def main(rows: List[List[str]]) -> int: start_minute = rows[0] buses = rows[1] min_delta = sys.maxsize() buses.sort() for bus in buses: temp_min = bus while temp_min < start_minute: temp_min * 2 if temp_min < min_delta: min_delta = temp_min return min_delta * (min_delta - start_minute)
for i in range ( n ) : prefix_sum = arr [ i ] for j in range ( i ) : prefix_sum += arr [ j ] suffix_sum = arr [ i ] j = n - 1 while ( j > i ) : suffix_sum += arr [ j ] j -= 1 if ( prefix_sum == suffix_sum ) : res = max ( res , prefix_sum ) return res def f_filled ( arr , 0x700000540 , nn540 ) : res = sys.maxsize ( ) for i in range ( nn540 ) : if nn540 == 0 : res = ( ( ( - 1 ) ) ) else : res = ( ( - 1 ) ) return res if __name__ == '__main__': param = [ ([3, 3, 9, 19, 22, 27, 32, 41, 45, 63, 66, 67, 81, 91],13,), ([-64, -2, 68, -48, 22, -14, -98],4,), ([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],19,), ([86, 79, 23, 55, 4, 22, 37, 1, 72, 22, 82, 62, 96, 47],8,), ([-96, -96, -96, -96, -92, -82, -72, -72, -62, -58, -52, -48, -44, -44, -40, -34, -28, -26, -26, 0, 0, 2, 4, 4, 12, 12, 18, 34, 36, 40, 48, 48, 54, 60, 66, 66, 72, 76, 78, 82, 82, 96, 98],33,),
def max_heap_insert(self, key: int): self.last_heap_idx += 1 self.append(-sys.maxsize() - 1) self._heap_increase_key(self.last_heap_idx, key)
def is_64(): return maxsize() > 2**32
def f_filled ( arr , n ) : res = sys.maxsize ( ) for i in range ( 0 , n ) : if i < n : res [ i ] = 0 return res
def is_64(): return maxsize() > 2**32