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

7493번 - Collisions 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 128 MB126533235.165%

문제

Identical small balls are located on a straight line and can move along this line only. Each ball moves with a constant velocity, but velocities of different balls may be different. When two balls meet, a perfectly elastic collision occurs. It’s a common-known physical fact, that when two equal-mass physical bodies A and B collide perfectly elastically, they swap their velocities, i. e. new A’s velocity is old B’s one, and new B’s is old A’s.

Your task is to write a program to find the total number of collisions.

입력

The first line at input contains the number of balls N (3N200000). Each of the following N lines contains 2 space-separated integers — the starting coordinate and the velocity of corresponding ball. All start coordinates are in range –1011< x< 1011, all velocities are in range –108< v< 108. All start coordinates are different. It’s guaranteed that each collision involves exactly two balls (none involves three or more balls together).

출력

Your program should output exactly one integer number in a single line – the total number of collisions (or 987654321987654321 if the number is infinite).

제한

예제 입력 1

3
-5 3
0 -1
7 -2

예제 출력 1

3

힌트

출처

ICPC > Regionals > Europe > Southeastern European Regional Contest > All-Ukrainian Collegiate Programming Contest > AUCPC 2010 C번

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

출처

대학교 대회

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

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