题意:给定 n 个长方体的长,宽,高,让你求高最大的时候体积最大是多少。

析:排序,用高和体积排序就好。

代码如下:

#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <cstring>
#include <set>
#include <queue>
#include <algorithm>
#include <vector>
#include <map>
#include <cctype>
#include <cmath>
#include <stack>
//#include <tr1/unordered_map>
#define freopenr freopen("in.txt", "r", stdin)
#define freopenw freopen("out.txt", "w", stdout)
using namespace std;
//using namespace std :: tr1; typedef long long LL;
typedef pair<int, int> P;
const int INF = 0x3f3f3f3f;
const double inf = 0x3f3f3f3f3f3f;
const LL LNF = 0x3f3f3f3f3f3f;
const double PI = acos(-1.0);
const double eps = 1e-8;
const int maxn = 100 + 5;
const LL mod = 10000000000007;
const int N = 1e6 + 5;
const int dr[] = {-1, 0, 1, 0, 1, 1, -1, -1};
const int dc[] = {0, 1, 0, -1, 1, -1, 1, -1};
const char *Hex[] = {"0000", "0001", "0010", "0011", "0100", "0101", "0110", "0111", "1000", "1001", "1010", "1011", "1100", "1101", "1110", "1111"};
inline LL gcd(LL a, LL b){ return b == 0 ? a : gcd(b, a%b); }
int n, m;
const int mon[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
const int monn[] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
inline int Min(int a, int b){ return a < b ? a : b; }
inline int Max(int a, int b){ return a > b ? a : b; }
inline LL Min(LL a, LL b){ return a < b ? a : b; }
inline LL Max(LL a, LL b){ return a > b ? a : b; }
inline bool is_in(int r, int c){
return r >= 0 && r < n && c >= 0 && c < m;
}
struct Node{
int h, w, l;
bool operator < (const Node &p) const{
return h > p.h || (h == p.h && h*w*l > p.l*p.h*p.w);
}
};
Node a[maxn]; int main(){
while(scanf("%d", &n) == 1 && n){
for(int i = 0; i < n; ++i) scanf("%d %d %d", &a[i].l, &a[i].w, &a[i].h); sort(a, a+n);
printf("%d\n", a[0].l*a[0].w*a[0].h); }
return 0;
}

最新文章

  1. html中使用js实现内容过长时部分
  2. 关于oracle with as用法
  3. Merge Intervals
  4. xamarin android——数据绑定到控件(一)
  5. 深入理解计算机系统第二版习题解答CSAPP 2.14
  6. javascript sort()与reverse()
  7. ContentProvider简要
  8. svn rm --keep-local ./QueryParser_kill.logs
  9. 程序员的一生时间90%是用在编程上,而剩余的10%是活在世界上。刚进CSDN的博客看到这么句话
  10. Ubuntu部署Jupyter
  11. cmake编译安装mysql 5.6.12
  12. Observer观察者模式与OCP开放-封闭原则
  13. LNMP shell
  14. Python练习三
  15. MySQL:数据库表的空间回收
  16. JqGrid: Add,Edit,Del in asp.net
  17. Hibernate的实体类中为什么要继承Serializable?
  18. org.jsoup.HttpStatusException: HTTP error fetching URL. Status=403
  19. C. Classy Numbers
  20. Domino中使用JAVA代理

热门文章

  1. 事件和委托:第 5 页 委托、事件与Observer设计模式
  2. 解决ssh无操作自动断开[转载,已经验证]
  3. .htaccess重写、安全防护、文件访问权限
  4. 创建SSH keys
  5. Sudoku Killer--hdu1426(数独 跟上一题差不多 但是输入时问题)
  6. HDU——1054 Strategic Game
  7. 转: ORACLE存储过程笔记3----流程控制
  8. Spring Data JPA 进阶
  9. 解决安装oracle11g r2时提示pdksh conflicts with ksh-20100621-2.el6.i686问题
  10. day5-WordCount