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 ...
随机推荐
- Design Circular Deque
Design your implementation of the circular double-ended queue (deque). Your implementation should su ...
- kafka 名词解释及原理解析过程(三)
为什么要了解这些名词的解释呢?因为在学一个新的知识或者领域的时候,我们需要知道它所定义的概念和名词意思,因为只有这样我们才能理解和掌握这个新的知识点,才能更加系统的掌握这个技术. 一.名词解释 1.b ...
- loback的介绍与配置-(通俗易通)
一.logback的配置介绍 Logback的配置分为三个内容:Logger.appender及layout Logger:作为日志的记录器,主要用于存放日志对象,也可以定义日志类型.级别. appe ...
- tabs 导航 及内容切换
<!-- 导航头 --> <div class="col-md-6" style="padding: 0px"> <ul id=& ...
- Windows32位或64位下载安装配置Scala
[学习笔记] Windows 32位或64位下载安装配置Scala: 1)下载地址:http://www.scala-lang.org/download/,看我的spark那节,要求scala是2.1 ...
- Let's Code
Let's Code Happy Coding, Happy OI #include <bits/stdc++.h> using namespace std; int main() { c ...
- kmp跑两串的最大相同前后缀 HDU2594
题意:http://acm.hdu.edu.cn/showproblem.php?pid=2594 如题. 思路: Next数组记录的是pos位置失配时要跑到哪里,所以最后得再添加一个字符‘#’. 连 ...
- Python运算符和编码
Python运算符和编码 一.格式化输出 现在有以下需求,让⽤户输入name, age, job,hobby 然后输出如下所⽰: ----------info of dogfa---------- n ...
- hdu 1305 还是字典树
#include<cstdio> #include<iostream> #include<string> #include<cstdlib> #defi ...
- 安装 node.js npm,cnpm
参考:https://blog.csdn.net/suiyuehuimou/article/details/74143436 https://www.liaoxuefeng.com/wiki/0014 ...