poj 2291/3637 水题排序
来源:互联网 发布:知乎精华化妆品 编辑:程序博客网 时间:2024/04/28 08:23
poj 2291题意:给你几根绳子,每根最大承重能力都不同,从中选出几根,问最大承重力量是多少?称重是选出绳子的最小值*根数(比如有1,10,15承重的3跟绳子,如果用一根的话,选15的,能承重15,用2根的话,用10和15的,能承重10*2=20,3根的话显然只能是1*3=3了,承重最大的当然是20。
poj3637题意:一堆物品的价格给出,已知一次买≥3个东西,最便宜的免费。问怎么买这些东西花钱最少。
2291代码:
#include <cstdio>#include <algorithm>#include <cstdlib>using namespace std;#define clr(s,t) memset(s,t,sizeof(s));#define N 1005int T,n;int s[N];int main(){ scanf("%d",&T); while(T--){ int i,j; int res = 0; scanf("%d",&n); for(i = 0;i<n;i++) scanf("%d",&s[i]); sort(s,s+n); for(i = 0;i<n;i++) res = max(res,s[i]*(n-i)); printf("%d\n",res); } return 0;}
3637代码:
#include <cstdio>#include <algorithm>#include <cstring>#include <cmath>using namespace std;#define clr(s,t) memset(s,t,sizeof(s))#define N 20005int T,n,s[N];int main(){ scanf("%d",&T); while(T--){ int i,res = 0;; scanf("%d",&n); for(i = 0;i<n;i++) scanf("%d",&s[i]); sort(s, s+n); for(i = n-3;i>=0;i-=3) res += s[i]; printf("%d\n",res); } return 0;}
0 0
- poj 2291/3637 水题排序
- POJ 2371排序水题
- POJ 2388 排序水题
- POJ-1128 拓扑排序水题
- poj[2487]排序题
- poj 2487 排序题
- POJ 2007 Scrambled Polygon 凸包加排序 水题一道
- POJ 1833排序 next_permutation()水过!
- poj 2388(超水) 排序
- POJ 3045 Cow Acrobats(排序题)
- POJ 1002 UVA 755 487--3279 电话排序 简单但不容易的水题
- POJ 3312 Mahershalalhashbaz, Nebuchadnezzar, and Billy Bob Benjamin Go to the Regionals (排序水题)
- POJ-1002(字符串+排序)
- 拓扑排序,poj 1094
- 拓扑排序,poj 1094
- POJ 1094 拓扑排序
- poj-1094拓扑排序
- poj 1094 拓扑排序
- js-案例:省市连动下拉框
- Java反射探索-----从类加载说起
- 日记
- 南大软院大神养成计划--day02
- ELK学习8_ELK数据流传输过程_问题总结1
- poj 2291/3637 水题排序
- 解决百度地图com.baidu.platform.comjni.map.commonmemcache.JNICommonMemCache.Create:()J问题
- hello, world
- Linux_文件系统、磁盘分区_RHEL7
- 南大软院大神养成计划——第二天
- Java中多态性的实现
- setEnabled
- Bind Function to Bootstrap Modal Event 模态对话框事件绑定函数
- jquery的$.when方法的运用