当前位置: 首页 > news >正文

hdoj5835【水题】

思路:不想说了。。具体看代码。。。

#include <iostream>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <math.h>
#include <queue>
#include <stack>
using namespace std;
#define INF 0x3f3f3f
#define pi acos(-1.0)
#define MAX 110
#define mod 9973
#define ll long long
int n,m;
int a[MAX];
int main()
{
    int t,i,j,k;
    scanf("%d",&t);
    for(k=1;k<=t;k++)
    {
        scanf("%d",&n);
        int sum=0;
        for(i=1;i<=n;i++)
        {
            scanf("%d",&a[i]);
            sum+=a[i];
        }
        printf("Case #%d: ",k);
        if(n==1)
        {
            if(a[1]>=2)
                printf("1\n");
            else 
                printf("0\n");
            continue;
        }
        sort(a+1,a+n+1);
        if(a[n]<=3*(sum-a[n]))
            printf("%d\n",sum/2);
        else
        {
            if(a[n]-3*(sum-a[n])>=2)
                printf("%d\n",(sum-a[n])*2+1);
            else
                printf("%d\n",(sum-a[n])*2);
        }
    }
    return 0;
}

转载于:https://www.cnblogs.com/keyboarder-zsq/p/5934874.html

相关文章:

  • Android ScrollView+ViewPager+PullToRefreshListView
  • CF #367 DIV2 E
  • dl标签和table标签
  • sql 分割字符串 存储过程
  • GUI之绘画控制
  • jmc远程监控java服务
  • 制作根文件系统的经验
  • SharePoint UserProfileService 接口列表 注解
  • Liferay 6.2 改造系列之二十二:如何发布WAR包
  • 关于投资那些事
  • FreeRTOS下的串口编程
  • YII2.0邮箱发送
  • 格式是否正确输入年、月、日判断
  • Learn GIT
  • Redis常用命令入门4:集合类型
  • 【mysql】环境安装、服务启动、密码设置
  • 5分钟即可掌握的前端高效利器:JavaScript 策略模式
  • CSS 三角实现
  • CSS 提示工具(Tooltip)
  • CSS实用技巧干货
  • hadoop集群管理系统搭建规划说明
  • JavaScript DOM 10 - 滚动
  • js数组之filter
  • LeetCode刷题——29. Divide Two Integers(Part 1靠自己)
  • PHP 的 SAPI 是个什么东西
  • spring cloud gateway 源码解析(4)跨域问题处理
  • thinkphp5.1 easywechat4 微信第三方开放平台
  • 高程读书笔记 第六章 面向对象程序设计
  • 判断客户端类型,Android,iOS,PC
  • 使用 5W1H 写出高可读的 Git Commit Message
  • 延迟脚本的方式
  • 转载:[译] 内容加速黑科技趣谈
  • RDS-Mysql 物理备份恢复到本地数据库上
  • 曜石科技宣布获得千万级天使轮投资,全方面布局电竞产业链 ...
  • ​Distil-Whisper:比Whisper快6倍,体积小50%的语音识别模型
  • ​sqlite3 --- SQLite 数据库 DB-API 2.0 接口模块​
  • ​卜东波研究员:高观点下的少儿计算思维
  • #100天计划# 2013年9月29日
  • (¥1011)-(一千零一拾一元整)输出
  • (12)Hive调优——count distinct去重优化
  • (C语言)输入自定义个数的整数,打印出最大值和最小值
  • (动态规划)5. 最长回文子串 java解决
  • (附源码)计算机毕业设计ssm电影分享网站
  • (六)什么是Vite——热更新时vite、webpack做了什么
  • (排序详解之 堆排序)
  • (一)C语言之入门:使用Visual Studio Community 2022运行hello world
  • (一)VirtualBox安装增强功能
  • (转)Google的Objective-C编码规范
  • (转)关于pipe()的详细解析
  • . NET自动找可写目录
  • .Net Core webapi RestFul 统一接口数据返回格式
  • .NET Core 将实体类转换为 SQL(ORM 映射)
  • .Net小白的大学四年,内含面经
  • @require_PUTNameError: name ‘require_PUT‘ is not defined 解决方法
  • @基于大模型的旅游路线推荐方案