CF203C.Photographer

普及/提高-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Valera's lifelong ambition was to be a photographer, so he bought a new camera. Every day he got more and more clients asking for photos, and one day Valera needed a program that would determine the maximum number of people he can serve.

The camera's memory is d megabytes. Valera's camera can take photos of high and low quality. One low quality photo takes a megabytes of memory, one high quality photo take b megabytes of memory. For unknown reasons, each client asks him to make several low quality photos and several high quality photos. More formally, the i-th client asks to make x__i low quality photos and y__i high quality photos.

Valera wants to serve as many clients per day as possible, provided that they will be pleased with his work. To please the i-th client, Valera needs to give him everything he wants, that is, to make x__i low quality photos and y__i high quality photos. To make one low quality photo, the camera must have at least a megabytes of free memory space. Similarly, to make one high quality photo, the camera must have at least b megabytes of free memory space. Initially the camera's memory is empty. Valera also does not delete photos from the camera so that the camera's memory gradually fills up.

Calculate the maximum number of clients Valera can successfully serve and print the numbers of these clients.

瓦列拉毕生的梦想是成为一名摄影师,因此他购买了一台新相机。每天,要求拍照的客户越来越多;某一天,瓦列拉需要一个程序来确定他每天最多能服务多少位客户。

相机的内存容量为 dd 兆字节(MB)。瓦列拉的相机可以拍摄高质量和低质量的照片。一张低质量照片占用 aa MB 的内存,一张高质量照片占用 bb MB 的内存。出于未知原因,每位客户都要求他拍摄若干张低质量照片和若干张高质量照片。更准确地说,第 ii 位客户要求拍摄 xix_i 张低质量照片和 yiy_i 张高质量照片。

瓦列拉希望在确保每位被服务的客户都对其工作感到满意的前提下,每天服务尽可能多的客户。要让第 ii 位客户满意,瓦列拉必须完全满足其要求,即为其拍摄 xix_i 张低质量照片和 yiy_i 张高质量照片。拍摄一张低质量照片,相机必须至少有 aa MB 的可用内存空间;同理,拍摄一张高质量照片,相机必须至少有 bb MB 的可用内存空间。初始时,相机内存为空。此外,瓦列拉不会从相机中删除任何照片,因此相机内存将逐渐被填满。

请计算瓦列拉最多能成功服务的客户人数,并输出这些客户的编号。

输入格式

The first line contains two integers n and d (1 ≤ n ≤ 105, 1 ≤ d ≤ 109) — the number of clients and the camera memory size, correspondingly. The second line contains two integers a and b (1 ≤ a ≤ b ≤ 104) — the size of one low quality photo and of one high quality photo, correspondingly.

Next n lines describe the clients. The i-th line contains two integers x__i and y__i (0 ≤ x__i, y__i ≤ 105) — the number of low quality photos and high quality photos the i-th client wants, correspondingly.

All numbers on all lines are separated by single spaces.

第一行包含两个整数 nn 和 dd(1 ≤ n ≤ 1051 ≤ n ≤ 10^5,1 ≤ d ≤ 1091 ≤ d ≤ 10^9)—— 分别表示客户数量和相机内存大小。
第二行包含两个整数 aa 和 bb(1 ≤ a ≤ b ≤ 1041 ≤ a ≤ b ≤ 10^4)—— 分别表示一张低质量照片和一张高质量照片的大小。

接下来的 nn 行描述各个客户。第 ii 行包含两个整数 xix_i 和 yiy_i(0 ≤ xi, yi ≤ 1050 ≤ x_i,\, y_i ≤ 10^5)—— 分别表示第 ii 位客户所需的低质量照片数量和高质量照片数量。

所有行中的数字均以单个空格分隔。

输出格式

On the first line print the answer to the problem — the maximum number of clients that Valera can successfully serve. Print on the second line the numbers of the client in any order. All numbers must be distinct. If there are multiple answers, print any of them. The clients are numbered starting with 1 in the order in which they are defined in the input data.

第一行输出问题的答案——Valera 最多能成功服务的客户数量。
第二行以任意顺序输出这些客户的编号,所有编号必须互不相同。若存在多个可行答案,输出任意一个即可。客户编号从 1 开始,按输入数据中定义的顺序依次编号。

输入输出样例

  • 输入#1

    3 10
    2 3
    1 4
    2 1
    1 0

    输出#1

    2
    3 2
  • 输入#2

    3 6
    6 6
    1 1
    1 0
    1 0

    输出#2

    1
    2

输入解题思路,AI测评打分。不知道怎么写?

首页