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

 #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. 【00】why集搜客网络爬虫?

    与各种大企业相比,大数据对于没有数据资源的个体而言是奢侈品. 然而在“互联网思维”.“互联网+”引领下,我们应当勇于实践和颠覆传统,将数据平民化. 不管你是财经.金融.经管.社科专业的技术小白,正在做 ...

  2. Obstack是C标准库里面对内存管理的GNU扩展

    Obstack是C标准库里面对内存管理的GNU扩展 Obstack介绍 Obstack初始化 在Obstack中申请对象 释放对象 申请growing object 获取Obstack状态 数据对齐 ...

  3. Spring boot 提高篇

    Spring boot 提高篇 上篇文章介绍了Spring boot初级教程:构建微服务:Spring boot 入门篇,方便大家快速入门.了解实践Spring boot特性:本篇文章接着上篇内容继续 ...

  4. cxf2.7.10 与 spring3.0.5集成

    开发环境: NetBeans7.4 Tomcat 6.0.32 一 服务端: 1:新建JavaWeb工程 cxfspring-server,导入jar包如下图所示: 2:在web.xml文件中添加如下 ...

  5. (?m)使用实例

    示例sql: # User@Host: zjzc_app[zjzc_app] @ [10.22.18.164] Id: 6069153 # Query_time: 153.908486 Lock_ti ...

  6. 用 Graphviz画神经网络图

    用 Graphviz . 以下代码提供一个例子, 具体使用时做简单修改即可. digraph G { rankdir=LR splines=line nodesep=.05; node [label= ...

  7. Php开发官方IDE ZEND

    From http://www.zend.com/en/products/studio 注:唯一的缺点是收费.

  8. UESTC_邱老师看电影 2015 UESTC Training for Dynamic Programming<Problem F>

    F - 邱老师看电影 Time Limit: 3000/1000MS (Java/Others)     Memory Limit: 65535/65535KB (Java/Others) Submi ...

  9. poj 1077-Eight(八数码+逆向bfs打表)

    The 15-puzzle has been around for over 100 years; even if you don't know it by that name, you've see ...

  10. C++对象模型浅析

    本文仅代表博主自己对C++内存对象模型的一点理解,如果文中有 理解偏差和不准确的地方,希望各位大大提出,我好及时改正. 本博文只对博主自己负责,不对任何人负责. 就如<深度探索C++对象模型&g ...