简单贪心。注意内存够大,能满足所有顾客的特殊情况。

 #include <iostream>
#include <cstring>
#include <algorithm> #define maxn 100010 using namespace std; typedef long long ll; struct node {
ll c,id;
}c[maxn]; bool cmp (node x,node y){
if (x.c<y.c)
return true ;
return false ;
} int main (){
ll n,d,x,y,a,b;
ll ans,sum;
while (cin>>n>>d){
cin>>a>>b;
for (int i=;i<n;i++){
cin>>x>>y;
c[i].c=a*x+b*y;
c[i].id=i+;
}
sort (c,c+n,cmp);
sum=ans=;
for (int i=;i<n;i++){
sum+=c[i].c;
if (sum>d){
ans=i;
break ;
}
if (i==n-) //所有顾客都能满足
ans=n;
}
cout<<ans<<endl;
for (int i=;i<ans;i++){
cout<<c[i].id<<" ";
}
cout<<endl;
}
return ;
}

CodeForces 203C Photographer的更多相关文章

  1. Codeforces Beta Round #14 (Div. 2) B. Young Photographer 水题

    B. Young Photographer 题目连接: http://codeforces.com/contest/14/problem/B Description Among other thing ...

  2. Codeforces Round #368 (Div. 2) A. Brain's Photos (水题)

    Brain's Photos 题目链接: http://codeforces.com/contest/707/problem/A Description Small, but very brave, ...

  3. Codeforces Round #368 (Div. 2) A. Brain's Photos 水题

    A. Brain's Photos 题目连接: http://www.codeforces.com/contest/707/problem/A Description Small, but very ...

  4. codeforces VK Cup 2015 - Qualification Round 1 B. Photo to Remember 水题

    B. Photo to Remember Time Limit: 1 Sec  Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/522/ ...

  5. python爬虫学习(5) —— 扒一下codeforces题面

    上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题 ...

  6. 【Codeforces 738D】Sea Battle(贪心)

    http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ...

  7. 【Codeforces 738C】Road to Cinema

    http://codeforces.com/contest/738/problem/C Vasya is currently at a car rental service, and he wants ...

  8. 【Codeforces 738A】Interview with Oleg

    http://codeforces.com/contest/738/problem/A Polycarp has interviewed Oleg and has written the interv ...

  9. CodeForces - 662A Gambling Nim

    http://codeforces.com/problemset/problem/662/A 题目大意: 给定n(n <= 500000)张卡片,每张卡片的两个面都写有数字,每个面都有0.5的概 ...

随机推荐

  1. css3属性:column分栏

    css3选择器中提出了分栏的属性,其浏览器支持情况为:Internet Explorer 10 和 Opera 支持 column 属性,Firefox 支持替代的 -moz-column 属性,Sa ...

  2. php pdf word excel 操作方法

    很早的时候,用php生成execl都是件麻烦的事,我一般都会用csv来替代,现在这类工具就很多了,并且比较成熟了.不光有excel的,word,pdf. 1,php excelreader操作exce ...

  3. RedHat下MySQL 5.6 安装、维护

    准备环境: RedHat 5系统.MySQL 5.6 rpm包 首先 上传mysql至服务器 1. 解压缩MySql [root@localhost]# tar -xvf MySQL-5.6.2_m5 ...

  4. 数据的加密传输——单片机上实现TEA加密解密算法

    各位大侠在做数据传输时,有没有考虑过把数据加密起来进行传输,若在串口或者无线中把所要传的数据加密起来,岂不是增加了通信的安全性.常用的加密解密算法比如DES.RSA等,受限于单片机的内存和运算速度,实 ...

  5. Unix/Linux环境C编程入门教程(31) 数学函数带你战胜企业面试

    1.函数介绍: abs()acos()asin()atan()atan2()ceil()cos()cosh()exp()frexp()ldexp()log()log10()pow()sin()sinh ...

  6. easyui 表单验证validatetype——支持自定义验证

    easyui 的validatebox()提供了自定义验证的方法,为此我把一些常用的数据验证汇总了一下,代码如下: 代码 Code highlighting produced by Actipro C ...

  7. Combinations 解答

    Question Given two integers n and k, return all possible combinations of k numbers out of 1 ... n. F ...

  8. HOWTO Use Python in the web — Python v3.0.1 documentation

    HOWTO Use Python in the web - Python v3.0.1 documentation mod_python¶ People coming from PHP often f ...

  9. 【转】Android LCD(二):LCD常用接口原理篇

    关键词:android LCD TFT TTL(RGB)  LVDS  EDP MIPI  TTL-LVDS  TTL-EDP 平台信息:内核:linux2.6/linux3.0系统:android/ ...

  10. iterator的简单用法

    // 给你写了个简单的例子,不知道合不合你的题意? vector<int>vertical; ; i<; i++) { vertical.push_back(i); } vector ...