Connection Status:
Competition Arena > ShoutterDiv2
SRM 580 · 2012-12-13 · by snuke · Brute Force
Class Name: ShoutterDiv2
Return Type: int
Method Name: count
Arg Types: (vector<int>, vector<int>)
Problem Statement

Problem Statement

A group of freshman rabbits has recently joined the Eel club. No two of the rabbits knew each other. Today, each of the rabbits went to the club for the first time. You are given int[]s s and t with the following meaning: For each i, rabbit number i entered the club at the time s[i] and left the club at the time t[i].

Each pair of rabbits that was in the club at the same time got to know each other, and they became friends on the social network service Shoutter. This is also the case for rabbits who just met for a single moment (i.e., one of them entered the club exactly at the time when the other one was leaving).

Compute and return the number of pairs of rabbits that became friends today.

Constraints

  • s and t will contain between 1 and 50 integers, inclusive.
  • s and t will contain the same number of elements.
  • Each integer in s and t will be between 0 and 100, inclusive.
  • For each i, t[i] will be greater than or equal to s[i].
Examples
0)
{1, 2, 4}
{3, 4, 6}
Returns: 2

Rabbit 0 and Rabbit 1 will be friends because both of them are in the club between time 2 and 3. Rabbit 0 and Rabbit 2 won't be friends because Rabbit 0 will leave the club before Rabbit 2 enters the club. Rabbit 1 and Rabbit 2 will be friends because both of them are in the club at time 4.

1)
{0}
{100}
Returns: 0
2)
{71,30}
{97,90}
Returns: 1
3)
{54,30,16}
{62,94,87}
Returns: 3
4)
{3,5,2,3}
{78,37,87,16}
Returns: 6

Submissions are judged against all 80 archived test cases, of which 5 are shown here. Case numbers match the judge’s.

Coding Area

Language: C++17 · define a public class ShoutterDiv2 with a public method int count(vector<int> s, vector<int> t) · 80 test cases · 2 s / 256 MB per case

Submitting as anonymous