Submission #56264187
Source Code Expand
Copy
n, m = map(int, input().split())a = list(map(int, input().split())) #len(a)==ndef is_possible(x, a, m):total = 0for ai in a:total += min(x, ai)if total > m:return Falsereturn Truedef find_maximum_x(n, m, a):left, right = 0, max(a)best_x = 0while left <= right:mid = (left + right) // 2if is_possible(mid, a, m):best_x = midleft = mid + 1else:right = mid - 1
n, m = map(int, input().split()) a = list(map(int, input().split())) #len(a)==n def is_possible(x, a, m): total = 0 for ai in a: total += min(x, ai) if total > m: return False return True def find_maximum_x(n, m, a): left, right = 0, max(a) best_x = 0 while left <= right: mid = (left + right) // 2 if is_possible(mid, a, m): best_x = mid left = mid + 1 else: right = mid - 1 return best_x result = find_maximum_x(n, m, a) if result == max(a): result = 'infinite' print(result)
Submission Info
Submission Time | |
---|---|
Task | C - Transportation Expenses |
User | kengchong |
Language | Python (PyPy 3.10-v7.3.12) |
Score | 300 |
Code Size | 636 Byte |
Status | AC |
Exec Time | 129 ms |
Memory | 114516 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 300 / 300 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt |
All | 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt, 01_test_01.txt, 01_test_02.txt, 01_test_03.txt, 01_test_04.txt, 01_test_05.txt, 01_test_06.txt, 01_test_07.txt, 01_test_08.txt, 01_test_09.txt, 01_test_10.txt, 01_test_11.txt, 01_test_12.txt, 01_test_13.txt, 01_test_14.txt, 01_test_15.txt, 01_test_16.txt, 01_test_17.txt, 01_test_18.txt, 01_test_19.txt, 01_test_20.txt, 01_test_21.txt, 01_test_22.txt, 01_test_23.txt, 01_test_24.txt, 01_test_25.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
00_sample_01.txt | AC | 63 ms | 76512 KB |
00_sample_02.txt | AC | 61 ms | 76240 KB |
00_sample_03.txt | AC | 62 ms | 76716 KB |
01_test_01.txt | AC | 111 ms | 114296 KB |
01_test_02.txt | AC | 115 ms | 113988 KB |
01_test_03.txt | AC | 97 ms | 113820 KB |
01_test_04.txt | AC | 120 ms | 113984 KB |
01_test_05.txt | AC | 129 ms | 113808 KB |
01_test_06.txt | AC | 129 ms | 113948 KB |
01_test_07.txt | AC | 115 ms | 113932 KB |
01_test_08.txt | AC | 126 ms | 113796 KB |
01_test_09.txt | AC | 76 ms | 86192 KB |
01_test_10.txt | AC | 84 ms | 89904 KB |
01_test_11.txt | AC | 98 ms | 114016 KB |
01_test_12.txt | AC | 113 ms | 113928 KB |
01_test_13.txt | AC | 97 ms | 113960 KB |
01_test_14.txt | AC | 118 ms | 114296 KB |
01_test_15.txt | AC | 112 ms | 114040 KB |
01_test_16.txt | AC | 104 ms | 114004 KB |
01_test_17.txt | AC | 121 ms | 113964 KB |
01_test_18.txt | AC | 97 ms | 114516 KB |
01_test_19.txt | AC | 97 ms | 114516 KB |
01_test_20.txt | AC | 62 ms | 76312 KB |
01_test_21.txt | AC | 92 ms | 113816 KB |
01_test_22.txt | AC | 99 ms | 113692 KB |
01_test_23.txt | AC | 103 ms | 113784 KB |
01_test_24.txt | AC | 110 ms | 113988 KB |
01_test_25.txt | AC | 100 ms | 113972 KB |