CodeForces 203C Photographer
简单贪心。注意内存够大,能满足所有顾客的特殊情况。
#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的更多相关文章
- Codeforces Beta Round #14 (Div. 2) B. Young Photographer 水题
B. Young Photographer 题目连接: http://codeforces.com/contest/14/problem/B Description Among other thing ...
- Codeforces Round #368 (Div. 2) A. Brain's Photos (水题)
Brain's Photos 题目链接: http://codeforces.com/contest/707/problem/A Description Small, but very brave, ...
- 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 ...
- 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/ ...
- python爬虫学习(5) —— 扒一下codeforces题面
上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题 ...
- 【Codeforces 738D】Sea Battle(贪心)
http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ...
- 【Codeforces 738C】Road to Cinema
http://codeforces.com/contest/738/problem/C Vasya is currently at a car rental service, and he wants ...
- 【Codeforces 738A】Interview with Oleg
http://codeforces.com/contest/738/problem/A Polycarp has interviewed Oleg and has written the interv ...
- CodeForces - 662A Gambling Nim
http://codeforces.com/problemset/problem/662/A 题目大意: 给定n(n <= 500000)张卡片,每张卡片的两个面都写有数字,每个面都有0.5的概 ...
随机推荐
- django中使用json.dumps处理数据时,在前台遇到字符转义的问题
django后台代码: import json ctx['dormitory_list'] = json.dumps([{", "is_checked": 1}, {&q ...
- 傻瓜式硬盘重装win7系统图文加视频教程
标准适用环境: win7系统还能用,但是想重装win7系统.[当然win7进不去也可以在PE进行] 其它 需要工具: win7 ISO镜像 | [ w ...
- C语言之预处理命令
/**************************************************************************** Title:C之预处理命令 Time:201 ...
- php文件处理
1. 将数据写入文件步骤 1. 打开这个文件,如果不存在,则新建文件 2. 将数据写入文件 3. 关闭文件 2. 从文件中读取数据步骤 1. 打开一个文件,如果不能打开,如文件不存在,应安全退出 2. ...
- QT 4.87 changes
http://blog.qt.io/blog/2015/05/26/qt-4-8-7-released/ Qt 4.8.7 is a bug-fix release. It maintains bot ...
- rc.local自启动学习
在CentOS系统下,主要有三种方法设置自己安装的程序开机启动.1.把启动程序的命令添加到/etc/rc.d/rc.local文件中,比如下面的是设置开机启动httpd. #!/bin/sh # # ...
- 关于oracle动态视图v$datafile和v$datafile_header(转)
v$datafile是从oracle的控制文件中获得的数据文件的信息v$datafile_header是从数据文件的头部在正常运行下,两者的检查点SCN值是一致的,但当datafile出现损坏时可以用 ...
- iframe父子页面互调方法和属性
1.iframe子页面调用 父页面js函数 子页面调用父页面函数只需要写上window.praent就可以了.比如调用a()函数,就写成: window.parent.a(); 子页面取父页面中的标签 ...
- UESTC_全都是秋实大哥 2015 UESTC Training for Search Algorithm & String<Problem J>
J - 全都是秋实大哥 Time Limit: 5000/2000MS (Java/Others) Memory Limit: 32000/32000KB (Java/Others) Subm ...
- JSONObject和JSONArray的简单使用(json-lib)
一. jar包 commons-lang.jar commons-beanutils.jar commons-collections.jar commons-logging.jar ezmorph.j ...