Submit solution

Points: 3 (partial)
Time limit: 2.0s
Memory limit: 512M

Problem type
Allowed languages
Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, CommonLisp, D, Dart, F#, Forth, Fortran, Go, Groovy, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, Nim, ObjC, OCaml, Octave, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig
2017 Fall Waterloo Local ACM Contest, Problem A

Vera has five sticks of distinct lengths l_1, l_2, l_3, l_4, l_5. Vera may choose any three of the five sticks to form the sides of a triangle. How many different triangles can Vera make? Each triangle must have positive area and sticks cannot be bent or cut.


Line 1 contains integers l_1, l_2, l_3, l_4, l_5\ (1 \le l_i \le 1000).


Print one line with one integer, the number of ways to form a triangle.

Sample Input 1

1 2 3 4 5

Sample Output 1


Sample Input 2

1 2 4 8 16

Sample Output 2



For the first example, the 3 ways to form a triangle are choosing sticks 2, 3, 4 or 2, 4, 5 or 3, 4, 5.


There are no comments at the moment.