Logo
(追記) (追記ここまで)

24575번 - Good Triplets 서브태스크다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 1024 MB51191946.341%

문제

Andrew is a very curious student who drew a circle with the center at (0, 0) and an integer circumference of C ≥ 3. The location of a point on the circle is the counter-clockwise arc length from the right-most point of the circle.

Andrew drew N ≥ 3 points at integer locations. In particular, the ith point is drawn at location Pi (0 ≤ Pi ≤ C − 1). It is possible for Andrew to draw multiple points at the same location.

A good triplet is defined as a triplet (a, b, c) that satisfies the following conditions:

  • 1 ≤ a < b < c ≤ N.
  • The origin (0, 0) lies strictly inside the triangle with vertices at Pa, Pb, and Pc. In particular, the origin is not on the triangle’s perimeter.

Lastly, two triplets (a, b, c) and (a', b', c') are distinct if a ≠ a', b ≠ b', or c ≠ c'.

Andrew, being a curious student, wants to know the number of distinct good triplets. Please help him determine this number.

입력

The first line contains the integers N and C, separated by one space.

The second line contains N space-separated integers. The ith integer is Pi (0 ≤ Pi ≤ C − 1).

출력

Output the number of distinct good triplets.

제한

서브태스크

번호배점제한
13

3 ≤ N ≤ 200, 3 ≤ C ≤ 106

23

3 ≤ N ≤ 106, 3 ≤ C ≤ 6 000

36

3 ≤ N ≤ 106, 3 ≤ C ≤ 106

P1, P2, . . . , PN are all distinct (i.e., every location contains at most one point)

43

3 ≤ N ≤ 106, 3 ≤ C ≤ 106

예제 입력 1

8 10
0 2 5 5 6 9 0 0

예제 출력 1

6

Andrew drew the following diagram.

The origin lies strictly inside the triangle with vertices P1, P2, and P5, so (1, 2, 5) is a good triplet. The other five good triplets are (2, 3, 6), (2, 4, 6), (2, 5, 6), (2, 5, 7), and (2, 5, 8).

힌트

출처

Olympiad > Canadian Computing Competition & Olympiad > 2022 > CCC 2022 Senior Division 4번

채점 및 기타 정보

  • 예제는 채점하지 않는다.
(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /