Acm:racing Gems-Maximum increment sequence

Source: Internet
Author: User

Racing Gems

You are playing a racing game. Your character starts at the x axis (y = 0) and proceeds to the race track, which have a boundary at  The line x = 0 and another at x = w.  You could start the race at any horizontal position you want, as long as it's within the track boundary.  The finish line was at y = h, and the game ends if you reach. You proceed at a fixed vertical velocity v, but can control your horizontal velocity to being any value betwee n v/r and v/r, and change it in any time.

There is n gems at specific points in the race track.  Your job is to collect as many gems as possible. How many gems can you collect?

Input

The first line of input contains four space-separated integers n, R, W, and H (1 n , 1 r , 1 W, h 109). Each of the following n lines contains II space-separated integers xi and y i, denoting the coordinate of the ith gem (0 xi W, 0 < yi h). There'll is at the most one gem per location.

The input does not include a value for v.

Output

Print, on a single line, the maximum number of gems so can be collected during the race.

Sample Input

Sample Output

3

5 1 10 10

8 8

5 1

4 6

4 7

7 9

Sample Input

Sample Output

3

5 1 100 100

27 75

79 77

40 93

62 41

52 45

Sample Input

Sample Output

4

10 3 30 30

14 9

2 20

3 23

15 19

13 5

17 24

6 16

21 5

14 10

6 S

/* /test instructions, run the sports car game, X direction speed for 1,y direction own control range between -1/r to 1/R. Give the coordinates of the coins, up to how many coins can be found. First of all, we can walk in the range of the starting point from the left and right two rays, if the next point in the current point of the Ray range, then this gold can be picked up. If it's not within the Ray range, it can't be picked up.

you can see that the first green point A can go directly to the point where there are two B and C, but B can only go to E, and C may walk to D, and then go from D to E; obviously a-c-d-e this path is longer, think of here, we can solve this problem: the coordinates of each point according to the velocity of the left and right displacement 1 The/R maps to the left and right two boundaries, and the left boundary takes precedence in ascending order of the left two boundaries, taking the maximum ascending sub-sequence on the rightmost boundary. Here, an iterator Upper_bound (a,a+n,x) is used to return the last address of the increment sequence from x in the A array. AC Code:/*

#include "algorithm" #include "iostream" #include "CString" #include "cstdlib" #include "Cstdio" #include "string" # Include "vector" #include "queue" #include "Cmath" using namespace std;typedef long long LL; #define MEMSET (x, y) memset (x, Y, sizeof (x)) #define MEMCPY (x, y) memcpy (x,y,sizeof) #define FK (x) cout<< "[" <<x<< "]\n" #define Bigfor (x) for (LL qq=1;qq<= T; qq++) const LL mx=1e5+5;struct Node {LL x,y;bool operator< (const Node &a) Const {RET Urn x < a.x;} void Add (LL r,ll w,ll xx,ll yy) {x=xx*r+yy;y= (w-xx) *r+yy;}} ND[MX]; ll Dp[mx];int Main () {ll n,r,w,h,x,y;while (~scanf ("%i64d%i64d%i64d%i64d", &n,&r,&w,&h)) {for (LL i=1; i <=n; i++) {scanf ("%i64d%i64d", &x,&y); Nd[i].add (r,w,x,y);} ll Ans=0;memset (dp,0x3f); sort (nd+1,nd+1+n); for (ll I=1; i<=n; i++) {ll tem=upper_bound (DP+1,DP+1+N,ND[I].Y)-&  DP[0]; ★ans = max (Ans,tem);DP [Tem]=nd[i].y;} printf ("%i64d", ans);} return 0;} /*/★ Ascending container: iterator lower_bound (const key_type &key): Returns an iterator [address], pointing to the key value >= keThe first element of Y. Iterator Upper_bound (const key_type &key): Returns an iterator [address] that points to the next element of the last element of the key value <=key. ★ Descending Container: Iterator lower_bound (const key_type &key): Returns an iterator [address] that points to the first element of the key value <= key. Iterator Upper_bound (const key_type &key): Returns an iterator [address] that points to the next element of the last element of the key value >=key. /*/

  

Acm:racing Gems-Maximum increment sequence

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.