Created
August 15, 2021 09:50
-
-
Save uchidama/6d290a777ae909c2d21c01e75235763c to your computer and use it in GitHub Desktop.
AtCoder Beginner Contest 163 [ D - Sum of Large Numbers ] https://atcoder.jp/contests/abc163/tasks/abc163_d
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
| ''' | |
| [問題] | |
| https://atcoder.jp/contests/abc163/tasks/abc163_d | |
| [解説] | |
| https://youtu.be/HVuSp_IhNZA?t=5554 | |
| なるほど感 | |
| https://atcoder.jp/contests/abc163/submissions/24993818 | |
| ''' | |
| import sys | |
| sys.setrecursionlimit(10 ** 6) # 再帰上限の引き上げ | |
| input = sys.stdin.readline | |
| INF = 2 ** 63 - 1 | |
| mod = 10 ** 9 + 7 | |
| N, K = map(int, input().split()) | |
| ans = 0 | |
| min = 0 | |
| Max = 0 | |
| for i in range(1, N + 2): | |
| # 最小値と最大値の計算。その間の数は全部生成できるので、Max - min + 1通り生成できる | |
| min += i - 1 | |
| Max += N + 1 - i | |
| if i >= K: | |
| ans += Max - min + 1 | |
| ans %= mod | |
| print(ans) | |
| ''' | |
| # 読み込み系テンプレ | |
| N, M = map(int, input().split()) | |
| N = int(input()) | |
| h_list = list(map(int, input().split())) | |
| sa = list(input()) # 一文字ずつバラす | |
| N = int(input()) | |
| A = [tuple(map(int, input().split())) for i in range(N)] | |
| # タプルの2番目の要素でソート | |
| A.sort(key=lambda x: x[1], reverse=True) | |
| # 昔のINF | |
| INF = 10**18+7 | |
| S = S.replace('\n', '') | |
| ''' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment