Skip to main content
Code Review

Return to Question

Commonmark migration
Source Link

An Association of Computer Scientists meets on a weekly basis. There is a certain number of seats in the meeting room and all members know their seats. For example, if there are 10 seats and only 5 members attending, each member will sit on his own seat, and there may be empty seats left between the members, because all have to sit on their 'reserved' seats.

If a member, sitting on seat Xi, starts or joins the discussion, exactly Ti people (after him) will take part of the discussion. For every member, we know his seat and his voice. Only those members who are within the reach of the previous member's voice can hear him and participate in the discussion. For example, if we are given the seat and the voice of a member, and they are 1, 7 (respectively), only people seated on seats within range of 1 to 8 (inclusive) can hear him and participate in the discussion.

An Association of Computer Scientists meets on a weekly basis. There is a certain number of seats in the meeting room and all members know their seats. For example, if there are 10 seats and only 5 members attending, each member will sit on his own seat, and there may be empty seats left between the members, because all have to sit on their 'reserved' seats.

If a member, sitting on seat Xi, starts or joins the discussion, exactly Ti people (after him) will take part of the discussion. For every member, we know his seat and his voice. Only those members who are within the reach of the previous member's voice can hear him and participate in the discussion. For example, if we are given the seat and the voice of a member, and they are 1, 7 (respectively), only people seated on seats within range of 1 to 8 (inclusive) can hear him and participate in the discussion.

An Association of Computer Scientists meets on a weekly basis. There is a certain number of seats in the meeting room and all members know their seats. For example, if there are 10 seats and only 5 members attending, each member will sit on his own seat, and there may be empty seats left between the members, because all have to sit on their 'reserved' seats.

If a member, sitting on seat Xi, starts or joins the discussion, exactly Ti people (after him) will take part of the discussion. For every member, we know his seat and his voice. Only those members who are within the reach of the previous member's voice can hear him and participate in the discussion. For example, if we are given the seat and the voice of a member, and they are 1, 7 (respectively), only people seated on seats within range of 1 to 8 (inclusive) can hear him and participate in the discussion.

Tweeted twitter.com/#!/StackCodeReview/status/447100048288284672
added 35 characters in body
Source Link
Jamal
  • 35.2k
  • 13
  • 134
  • 238

I'm sort-of new here, and I need some help refactoring my solution to the problem below:

Input:Input:

N - number of members attending

Xi - seat of member i (for all i=1,2,...N), Li - his voice

Output:Output:

The number of people participating in the discussion after member i.

Example Input:

5

1 7

2 3

8 7

10 5

100 2

Output:

4

1Example Input:

2

5
1 7
2 3
8 7
10 5
100 2

1Output:

1

4
1
2
1
1

I'm sort-of new here, and I need some help refactoring my solution to the problem below:

Input:

N - number of members attending

Xi - seat of member i (for all i=1,2,...N), Li - his voice

Output:

The number of people participating in the discussion after member i.

Example Input:

5

1 7

2 3

8 7

10 5

100 2

Output:

4

1

2

1

1

I need some help refactoring my solution to the problem below:

Input:

N - number of members attending

Xi - seat of member i (for all i=1,2,...N), Li - his voice

Output:

The number of people participating in the discussion after member i.

Example Input:

5
1 7
2 3
8 7
10 5
100 2

Output:

4
1
2
1
1
Minor formatting
Source Link
Corbin
  • 10.6k
  • 2
  • 31
  • 51

An Association of Computer Scientists meets on a weekly basis. There is a certain number of seats in the meeting room and all members know their seats. For example, if there are 10 seats and only 5 members attending, each member will sit on his own seat, and there may be empty seats left between the members, because all have to sit on their 'reserved' seats.

If a member, sitting on seat Xi, starts or joins the discussion, exactly Ti people (after him) will take part of the discussion. For every member, we know his seat and his voice. Only those members who are within the reach of the previous member's voice can hear him and participate in the discussion. For example, if we are given the seat and the voice of a member, and they are 1, 7 (respectively), only people seated on seats within range of 1 to 8 (inclusive) can hear him and participate in the discussion.

Input:

NProblem Statement - number of members attending

Xi - seat of member i (for all i=1,2,...N), Li - his voice

An Association of Computer Scientists meets on a weekly basis. There is a certain number of seats in the meeting room and all members know their seats. For example, if there are 10 seats and only 5 members attending, each member will sit on his own seat, and there may be empty seats left between the members, because all have to sit on their 'reserved' seats.

Output:

If a member, sitting on seat Xi, starts or joins the discussion, exactly Ti people (after him) will take part of the discussion. For every member, we know his seat and his voice. Only those members who are within the reach of the previous member's voice can hear him and participate in the discussion. For example, if we are given the seat and the voice of a member, and they are 1, 7 (respectively), only people seated on seats within range of 1 to 8 (inclusive) can hear him and participate in the discussion.

The number of people participating in the discussion after member iExample Data.

Example Input:

5

1 7

2 3

8 7

10 5

100 2

Output:

4

1

2

1

1

Input:

N - number of members attending

Xi - seat of member i (for all i=1,2,...N), Li - his voice

Output:

The number of people participating in the discussion after member i.

Example Input:

5

1 7

2 3

8 7

10 5

100 2

Output:

4

1

2

1

1

An Association of Computer Scientists meets on a weekly basis. There is a certain number of seats in the meeting room and all members know their seats. For example, if there are 10 seats and only 5 members attending, each member will sit on his own seat, and there may be empty seats left between the members, because all have to sit on their 'reserved' seats.

If a member, sitting on seat Xi, starts or joins the discussion, exactly Ti people (after him) will take part of the discussion. For every member, we know his seat and his voice. Only those members who are within the reach of the previous member's voice can hear him and participate in the discussion. For example, if we are given the seat and the voice of a member, and they are 1, 7 (respectively), only people seated on seats within range of 1 to 8 (inclusive) can hear him and participate in the discussion.

Input:

N - number of members attending

Xi - seat of member i (for all i=1,2,...N), Li - his voice

Output:

The number of people participating in the discussion after member i.

Example Input:

5

1 7

2 3

8 7

10 5

100 2

Output:

4

1

2

1

1

Problem Statement

An Association of Computer Scientists meets on a weekly basis. There is a certain number of seats in the meeting room and all members know their seats. For example, if there are 10 seats and only 5 members attending, each member will sit on his own seat, and there may be empty seats left between the members, because all have to sit on their 'reserved' seats.

If a member, sitting on seat Xi, starts or joins the discussion, exactly Ti people (after him) will take part of the discussion. For every member, we know his seat and his voice. Only those members who are within the reach of the previous member's voice can hear him and participate in the discussion. For example, if we are given the seat and the voice of a member, and they are 1, 7 (respectively), only people seated on seats within range of 1 to 8 (inclusive) can hear him and participate in the discussion.

Example Data

Input:

N - number of members attending

Xi - seat of member i (for all i=1,2,...N), Li - his voice

Output:

The number of people participating in the discussion after member i.

Example Input:

5

1 7

2 3

8 7

10 5

100 2

Output:

4

1

2

1

1

Source Link
Loading
lang-cpp

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