Problem A

Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 32768/32768K (Java/Other)
Total Submission(s) : 104   Accepted Submission(s) : 32
Problem Description
Mr. B, Mr. G, Mr. M and their coach Professor S are planning their way to Warsaw for the ACM-ICPC World Finals. Each of the four has a square-shaped suitcase with side length Ai (1<=i<=4) respectively. They want to pack their suitcases into a large square box. The heights of the large box as well as the four suitcases are exactly the same. So they only need to consider the large box’s side length. Of course, you should write a program to output the minimum side length of the large box, so that the four suitcases can be put into the box without overlapping.
 
Input
Each test case contains only one line containing 4 integers Ai (1<=i<=4, 1<=Ai<=1,000,000,000) indicating the side length of each suitcase.
Output
For each test case, display a single line containing the case number and the minimum side length of the large box required.
 
Sample Input
2 2 2 2
2 2 2 1
 
Sample Output
Case 1: 4
Case 2: 4
[hint] For the first case, all suitcases have size 2x2. So they can perfectly be packed in a 4x4 large box without wasting any space. For the second case, three suitcases have size 2x2 and the last one is 1x1. No matter how you rotate or move the suitcases, the side length of the large box must be at least 4. [/hint]
#include <iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int a[];
int i,ans;
int cmp(int a,int b)
{
return a>b;
}
int main()
{
int t=;
while(~scanf("%d",&a[]))
{
t++;
for(i=;i<=;i++)
scanf("%d",&a[i]); sort(a,a+,cmp); //先排序
ans=a[]+a[];
printf("Case %d: %d\n",t,ans);
// printf("**%d\n",0x7fffffff);
}
return ;
}

Problem A的更多相关文章

  1. 1199 Problem B: 大小关系

    求有限集传递闭包的 Floyd Warshall 算法(矩阵实现) 其实就三重循环.zzuoj 1199 题 链接 http://acm.zzu.edu.cn:8000/problem.php?id= ...

  2. No-args constructor for class X does not exist. Register an InstanceCreator with Gson for this type to fix this problem.

    Gson解析JSON字符串时出现了下面的错误: No-args constructor for class X does not exist. Register an InstanceCreator ...

  3. C - NP-Hard Problem(二分图判定-染色法)

    C - NP-Hard Problem Crawling in process... Crawling failed Time Limit:2000MS     Memory Limit:262144 ...

  4. Time Consume Problem

    I joined the NodeJS online Course three weeks ago, but now I'm late about 2 weeks. I pay the codesch ...

  5. Programming Contest Problem Types

        Programming Contest Problem Types Hal Burch conducted an analysis over spring break of 1999 and ...

  6. hdu1032 Train Problem II (卡特兰数)

    题意: 给你一个数n,表示有n辆火车,编号从1到n,入站,问你有多少种出站的可能.    (题于文末) 知识点: ps:百度百科的卡特兰数讲的不错,注意看其参考的博客. 卡特兰数(Catalan):前 ...

  7. BZOJ2301: [HAOI2011]Problem b[莫比乌斯反演 容斥原理]【学习笔记】

    2301: [HAOI2011]Problem b Time Limit: 50 Sec  Memory Limit: 256 MBSubmit: 4032  Solved: 1817[Submit] ...

  8. [LeetCode] Water and Jug Problem 水罐问题

    You are given two jugs with capacities x and y litres. There is an infinite amount of water supply a ...

  9. [LeetCode] The Skyline Problem 天际线问题

    A city's skyline is the outer contour of the silhouette formed by all the buildings in that city whe ...

  10. PHP curl报错“Problem (2) in the Chunked-Encoded data”解决方案

    $s = curl_init(); curl_setopt($s, CURLOPT_POST, true); curl_setopt($s, CURLOPT_POSTFIELDS, $queryStr ...

随机推荐

  1. 利用PYTHON设计计算器功能

    通过利用PYTHON 设计处理计算器的功能如: 1 - 2 * ( (60-30 +(-40/5) * (9-2*5/3 + 7 /3*99/4*2998 +10 * 568/14 ))- (-4*3 ...

  2. android.telephony.SmsManager 短信笔记

    android 几种发送短信的方法 http://www.oschina.net/question/163910_27409 <uses-permission android:name=&quo ...

  3. table可更改th大小的jQuery插件

    (function ($) { $.fn.resizetable = function () { var tableObj = $(this); var inResizeRange = false; ...

  4. 正则表达式 Pattern & Matcher

    1 compile and pattern Pattern类用于创建一个正则表达式,也可以说创建一个匹配模式,它的构造方法是私有的,不可以直接创建,但可以通过Pattern.complie(Strin ...

  5. 嵌套json

    今天一个客户问怎样把表中相同键值对应的文本按照一定顺序拼接起来.如果使用SQL实现将非常麻烦,并且效率低下.GP4.1以后提供了一个函数array_agg可以方便快捷,高效的实现该功能 比如原始查询是 ...

  6. android网络编程之HttpUrlConnection的讲解--实现文件断点下载

    1.没有实现服务器端,下载地址为网上的一个下载链接. 2.网络开发不要忘记在配置文件中添加访问网络的权限 <uses-permission android:name="android. ...

  7. iOS中静态库-.a文件生成和使用

    最近在使用使用一个网上的Demo的时候. 出现另一令人烦恼的问题 . 就是它里面有嵌套的工程. 如下图所示. 工程里面还嵌套有一个工程. 真的是让人煞费苦心 …其实这个问题看起来并不是很难, 如果是一 ...

  8. AutoMapper 自动映射工具

    先引用对应的DLL. 11.转换匿名对象 结合LINQ映射新的实体类. using System;using System.Collections.Generic;using System.Linq; ...

  9. 好用的API文档--在线版

    安卓在线api http://www.android-doc.com/reference/packages.html

  10. 避免IE执行AJAX时,返回JSON出现下载文件

    <bean id="mappingJacksonHttpMessageConverter" class="org.springframework.http.conv ...