This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from collections import defaultdict | |
| N = int(input()) | |
| events = defaultdict(int) | |
| for _ in range(N): | |
| A, B = map(int, input().split()) | |
| events[A] += 1 | |
| events[A + B] -= 1 | |
| days = sorted(events.keys()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import bisect | |
| N = int(input()) | |
| A = [int(input()) for _ in range(N)][::-1] | |
| lis = [] | |
| for i in range(N): | |
| idx = bisect.bisect_right(lis, A[i]) | |
| if idx == len(lis): | |
| lis.append(A[i]) | |
| else: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import bisect | |
| N = int(input()) | |
| WH = [list(map(int, input().split())) for _ in range(N)] | |
| WH.sort(key=lambda x: (x[0], -x[1])) | |
| lis = [] | |
| H = [h for _, h in WH] | |
| for h in H: | |
| idx = bisect.bisect_left(lis, h) | |
| if idx == len(lis): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import bisect | |
| N = int(input()) | |
| AB = [list(map(int, input().split())) for _ in range(N)] | |
| AB.sort(key=lambda x: (x[0], -x[1])) | |
| lis = [] | |
| B = [b for _, b in AB] | |
| for b in B: | |
| idx = bisect.bisect_left(lis, b) | |
| if idx == len(lis): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import bisect | |
| W, H = map(int, input().split()) | |
| N = int(input()) | |
| pq = [list(map(int, input().split())) for _ in range(N)] | |
| A = int(input()) | |
| a = list(map(int, input().split())) | |
| B = int(input()) | |
| b = list(map(int, input().split())) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def ncr(n, r, m): | |
| # nCr = n! / (r! * (n-r)!) | |
| # a / b (mod p) = a * b ** (p-2) (mod p) | |
| if n >= r: | |
| return fact[n] * pow(fact[r] * fact[n - r] % m, m - 2, m) % m | |
| else: | |
| return 0 | |
| def solv(): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def check(x): | |
| # 高度xですべて割れるか? | |
| limits = [0] * N | |
| for i in range(N): | |
| h, s = HS[i] | |
| if h > x: # 高度xが初期高度より高いとだめ | |
| return False | |
| limits[i] = (x - h) // s | |
| limits.sort() | |
| for i in range(N): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| N = int(input()) | |
| A = list(map(int, input().split())) | |
| # j - i = Ai + Aj | |
| # j - Aj = i + Ai | |
| cnt = {} | |
| for j in range(N): | |
| val = j - A[j] | |
| if val not in cnt: | |
| cnt[val] = 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| N = int(input()) | |
| sums = [] | |
| diffs = [] | |
| for _ in range(N): | |
| x, y = map(int, input().split()) | |
| sums.append(x + y) | |
| diffs.append(x - y) | |
| ans = max(max(sums) - min(sums), max(diffs) - min(diffs)) | |
| print(ans) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import bisect | |
| N, M, P = map(int, input().split()) | |
| A = list(map(int, input().split())) | |
| B = sorted(list(map(int, input().split()))) | |
| sumB = [0] | |
| for i in range(M): | |
| sumB.append(sumB[-1] + B[i]) | |
| ans = 0 | |
| for a in A: |
NewerOlder