Last active
July 9, 2021 14:01
-
-
Save uchidama/625454e86fd5c8bd2af411a02d5b5d54 to your computer and use it in GitHub Desktop.
AtCoder Beginner Contest 175 [ B - Making Triangle ] https://atcoder.jp/contests/abc175/tasks/abc175_b
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/abc175/tasks/abc175_b | |
| [解説] | |
| https://atcoder.jp/contests/abc175/editorial/50 | |
| [参考] | |
| http://physics.thick.jp/Mathematics_A/Section5/5-3.html | |
| 三角形には、2つの辺の長さを足し合わせると残りの1つの辺の長さより長くなる。 | |
| ''' | |
| import sys | |
| import itertools | |
| sys.setrecursionlimit(10 ** 6) # 再帰上限の引き上げ | |
| input = sys.stdin.readline | |
| INF = 2 ** 63 - 1 | |
| N = int(input()) | |
| A = list(map(int, input().split())) | |
| ans = 0 | |
| for v in itertools.combinations(range(N), 3): | |
| L = [A[v[0]],A[v[1]],A[v[2]]] | |
| L.sort() | |
| # 三角形には、2つの辺の長さを足し合わせると残りの1つの辺の長さより長くなる。 | |
| if L[0] != L[1] and L[1] != L[2] and L[0] + L[1] > L[2]: | |
| ans += 1 | |
| print(ans) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment