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

 #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. POJ 2488 A Knight's Journey(DFS)

    A Knight's Journey Time Limit: 1000MSMemory Limit: 65536K Total Submissions: 34633Accepted: 11815 De ...

  2. ASP.NET MVC 4.0 学习5-ActionResult

    一,Controller簡介 Controller擔任了資料傳遞的角色,負責流程控制,決定存取哪個Model以及決定顯示哪個View頁面,即ASP.NET MVC中有關於『傳遞』的任務皆由Contro ...

  3. python操作redis-过期时间

    #!/usr/bin/python #!coding:utf-8 import time import redis if __name__ == "__main__": try: ...

  4. 深入学习微框架Spring-boot

    深入学习微框架:Spring Boot 深入学习微框架:Spring Boot

  5. TENX_ASM.uew

    /L14"TENX ASM" Nocase Line Comment = ; File Extensions = INC ASM LST H /Colors = ,,,,, /Co ...

  6. g++ error: expected nested-name-specifier before 'XXX'

    template <typename addrT=int,typename valuT=int,typename stream_addrT=bm_addr,typename stream_siz ...

  7. 其中 (%{WORD:x_forword}|-) |表示或的意思

    121.40.205.143 [30/Aug/2016:14:03:08 +0800] "GET /resources/images/favicon.ico HTTP/1.1" - ...

  8. Jquery时间快捷控件(Jtime)配置v1.0

    1.脚本代码行 /** * @title 时间工具类 * @note 本类一律违规验证返回false * @author {boonyachengdu@gmail.com} * @date 2013- ...

  9. java没有条件编译

    摘自http://maosidiaoxian.iteye.com/blog/1290740 条件编译绝对是一个好东西.如在C或CPP中,可以通过预处理语句来实现条件编译.代码如下: #IFDEF DE ...

  10. IOS 定位 单例

    + (SCLocationController *)sharedController { static SCLocationController *sharedController = nil; st ...