Codeforces Round #590 (Div. 3) A. Equalize Prices Again
链接:
https://codeforces.com/contest/1234/problem/A
题意:
You are both a shop keeper and a shop assistant at a small nearby shop. You have n goods, the i-th good costs ai coins.
You got tired of remembering the price of each product when customers ask for it, thus you decided to simplify your life. More precisely you decided to set the same price for all n goods you have.
However, you don't want to lose any money so you want to choose the price in such a way that the sum of new prices is not less than the sum of the initial prices. It means that if you sell all n goods for the new price, you will receive at least the same (or greater) amount of money as if you sell them for their initial prices.
On the other hand, you don't want to lose customers because of big prices so among all prices you can choose you need to choose the minimum one.
So you need to find the minimum possible equal price of all n goods so if you sell them for this price, you will receive at least the same (or greater) amount of money as if you sell them for their initial prices.
You have to answer q independent queries.
思路:
就求个平均值向上取整.
代码:
#include <bits/stdc++.h>
using namespace std;
int main()
{
int t;
scanf("%d", &t);
while (t--)
{
int n, sum = 0, a;
scanf("%d", &n);
for (int i = 1;i <= n;i++)
scanf("%d", &a), sum += a;
printf("%d\n", (sum+n-1)/n);
}
return 0;
}
Codeforces Round #590 (Div. 3) A. Equalize Prices Again的更多相关文章
- Codeforces Round #570 (Div. 3) B. Equalize Prices
原文链接https://codeforces.com/contest/1183/problem/B 题意:进行Q组测试,在每组中有长度为n的数组a[i],然后现在给你一个K,问你找到一个bi使得|ai ...
- Codeforces Round #570 (Div. 3) B. Equalize Prices、C. Computer Game、D. Candy Box (easy version)、E. Subsequences (easy version)
B题题意: 给你n个物品的价格,你需要找出来一个值b,使得每一个物品与这个b的差值的绝对值小于k.找到最大的b输出,如果找不到,那就输出-1 题解: 很简单嘛,找到上下限直接二分.下限就是所有物品中最 ...
- Codeforces Round #590 (Div. 3) Editorial
Codeforces Round #590 (Div. 3) Editorial 题目链接 官方题解 不要因为走得太远,就忘记为什么出发! Problem A 题目大意:商店有n件商品,每件商品有不同 ...
- Codeforces Round #590 (Div. 3)
A. Equalize Prices Again 题目链接:https://codeforces.com/contest/1234/problem/A 题意:给你 n 个数 , 你需要改变这些数使得这 ...
- Codeforces Round #590 (Div. 3)(e、f待补
https://codeforces.com/contest/1234/problem/A A. Equalize Prices Again #include<bits/stdc++.h> ...
- (原创)Codeforces Round #550 (Div. 3) D. Equalize Them All
D. Equalize Them All time limit per test 2 seconds memory limit per test 256 megabytes input standar ...
- Codeforces Round #590 (Div. 3) E. Special Permutations
链接: https://codeforces.com/contest/1234/problem/E 题意: Let's define pi(n) as the following permutatio ...
- Codeforces Round #590 (Div. 3) D. Distinct Characters Queries(线段树, 位运算)
链接: https://codeforces.com/contest/1234/problem/D 题意: You are given a string s consisting of lowerca ...
- Codeforces Round #590 (Div. 3) C. Pipes
链接: https://codeforces.com/contest/1234/problem/C 题意: You are given a system of pipes. It consists o ...
随机推荐
- C语言--单层循环结构
一.PTA实验作业 题目1:最佳情侣身高 1.实验代码 int N, i; float height; char sex; printf("输入用户个数:\n"); scanf(& ...
- centos7 虚拟机 A start job is running for /etc/rc.d/rc.local Comp。。。
一直卡这F5查看日志,最后一行出现A start job is running for /etc/rc.d/rc.local Comp... 原因是rc.local权限设错了解决方法:1.进入单用户模 ...
- dubbo分布式服务框架-study2
本文开始对springboot+dubbo集成,使用的版本为springboot 2.0.0.dubbo 2.0.0,步骤如下: 1.添加依赖: <dependency> <grou ...
- RabbitMQ 幂等性概念及业界主流解决方案
RabbitMQ 幂等性概念及业界主流解决方案 2019年01月24日 15:57:03 JAVA@架构 阅读数:506 一.什么是幂等性 可以参考数据库乐观锁机制,比如执行一条更新库存的 SQL ...
- (十五)mybatis 逆向工程
目录 为什么需要逆向工程 使用方法 如何读懂生成的代码 总结 为什么需要逆向工程 对于数据库中的那么多的表 ,基本的 CRUD 操作 ,以及 mybatis 需要使用的 接口.mapper ,这些工作 ...
- Photon Server 实现注册与登录(四) --- 服务端响应登陆和注册
前面已经整理过了服务端代码,MyGameServer.cs 和 ClientPeer.cs 对请求和响应进行了拆分.接下来处理对前端的响应 一.响应登陆请求 之前整理中,响应前端请求主要在类Clien ...
- 【01字典树】hdu-5536 Chip Factory
[题目链接] http://acm.hdu.edu.cn/showproblem.php?pid=5536 [题意] 求一个式子,给出一组数,其中拿出ai,aj,ak三个数,使得Max{ (ai+aj ...
- outlook邮箱备份
- [Tarjan系列] 无向图e-DCC和v-DCC的缩点
上一篇讲了如何应用Tarjan算法求出e-DCC和v-DCC. 那么这一篇就是e-DCC和v-DCC的应用之一:缩点. 先讲e-DCC的缩点. 我们把每一个e-DCC都看成一个节点,把所有桥边(x,y ...
- pm2 常用操作
PM2全局安装 npm i pm2 -g PM2启动.net core pm2 start "dotnet xxx.dll" --name api //name后面跟你要取的名字 ...