C. Photographer
来源:互联网 发布:单片机产生方波 编辑:程序博客网 时间:2024/05/14 03:29
解题说明:此题类似于一个背包问题,在容量一定的情况下,尽可能放入物体,保证放入的总数最大。想法是对物体从小到大排序,然后放入进行,为了记录下标,这里用到了C++里面 pair容器,sort对pair排序时针对的是第一个元素。
#include <iostream>#include<algorithm>#include<cstdio>#include <cstring>#include<string>using namespace std;pair<int,int> v[100100];int n,d,a,b,x,y,i,j;int main(){cin>>n>>d>>a>>b;for(i=0;i<n;++i){scanf("%d%d",&x,&y);v[i].first=x*a+b*y;v[i].second=i+1;}sort(v,v+n);for(i=0;i<n;++i){d-=v[i].first;if(d<0){cout<<i<<endl;break;}if(i==n-1){cout<<n<<endl;}}for(j=0;j<i;++j){cout<<v[j].second<<' ';}cout<<endl;return 0;}
- C. Photographer
- Codeforces Round #128 (Div. 2) C. Photographer
- Nudnik Photographer
- 1260. Nudnik Photographer
- 1260. Nudnik Photographer dp
- Ural 1260. Nudnik Photographer
- URAL 1260. Nudnik Photographer
- Photographer (SDUT 2063)
- ural 1260. Nudnik Photographer
- Ural 1260 Nudnik Photographer
- 14B - Young Photographer
- Ural 1260. A nudnik photographer
- codeforces 14B. Young Photographer
- Ural 1260. Nudnik Photographer DP
- ural 1260. Nudnik Photographer(dp)
- Nudnik Photographer -Ural1260动态规划
- CodeForces 14B Young Photographer
- CANON DSLR: The Ultimate Photographer's Guide
- 开发者必备:测试网站速度的五个免费在线工具
- OCP-1Z0-052-V8.02-94题
- js中cookie的使用详细分析
- VS2010 NVIDIA OpenCL 开发环境配置
- C++学习笔记(二)联想容器
- C. Photographer
- 不要后悔
- 2001 中美黑客
- C++学习笔记(三) 迭代器
- Logical Storage Structures
- poj1258
- myeclipse插件SVN使用
- Red Hat AS 5.5(64Bit)安装Oracle(10g-补丁10.2.0.5)
- C++多态详解