CF1234A Equalize Prices】的更多相关文章

洛谷 CF1234A Equalize Prices Again 洛谷传送门 题目描述 You are both a shop keeper and a shop assistant at a small nearby shop. You have nn goods, the ii -th good costs a_i*a**i* coins. You got tired of remembering the price of each product when customers ask fo…
链接: 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 fo…
题目链接:codeforces.com/problemset/problem/1183/B 题意:给你 n 个数,每个数能在k范围内上下浮动,求能否使所有数相等,能输出相等的最大值,不能输出 -1. 思路: 因为要求最大,所以将所有数向上浮动k,找到他们的最大最小值,如果相差不超过2*k,最小值即为答案. AC代码: #include<bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while(t-…
原文链接https://codeforces.com/contest/1183/problem/B 题意:进行Q组测试,在每组中有长度为n的数组a[i],然后现在给你一个K,问你找到一个bi使得|ai-bi|<=k并且bi最大.如果找不到,就输出-1.思路:这个也就关系到,最大值max,最小值min,和K,至于中间的数,我们不用去管,现在一个排序,如果max-min<=2*k,那么就输出min+k,否者就输出-1.(为什么要在2*k的范围找???想想看)代码: #include"io…
B题题意: 给你n个物品的价格,你需要找出来一个值b,使得每一个物品与这个b的差值的绝对值小于k.找到最大的b输出,如果找不到,那就输出-1 题解: 很简单嘛,找到上下限直接二分.下限就是所有物品中最小的价格.上限就是所有物品中最大价格加上k 代码: 1 #include<stdio.h> 2 #include<string.h> 3 #include<iostream> 4 #include<algorithm> 5 #include<map>…
There are n products in the shop. The price of the ii-th product is aiai. The owner of the shop wants to equalize the prices of all products. However, he wants to change prices smoothly. In fact, the owner of the shop can change the price of some pro…
A. Equalize Prices Again 题目链接:https://codeforces.com/contest/1234/problem/A 题意:给你 n 个数 , 你需要改变这些数使得这 n 个数的值相等 , 并且要求改变后所有数的和需大于等于原来的所有数字的和 , 然后输出满足题意且改变后最小的数值 分析: 签到题.记原来 n 个数的和为 sum , 先取这些数的平均值 ave , 然后每次判断 ave * n >= sum 是否成立成立则直接输出 , 不成立将 ave ++ #…
https://codeforces.com/contest/1234/problem/A A. Equalize Prices Again #include<bits/stdc++.h> using namespace std; typedef long long ll; int main(){ int n,a; int t; cin>>t; ll sum = ,ans; while(t--){ cin>>n;sum = ; ;i < n;++i){ cin&g…
拿DIV找快乐... 当场过了A-B1-B2-C 写D差5分钟写的是正解...留坑补FG A. Equalize Prices Again 直接判断sum%n==0?sum/n:sum/n+1 B1,B2. Social Network (hard version) 模拟类似什么cache之类的... 其实很简单直接用set保存内部出现过的元素,然后用list模拟双向链表,直接判断就可以了. C.其实很简单,1-2都是一类,3-6都是一类.那么一列两个3-6可以让人换到另外的一行去,否则就直行,…
题目链接:Round #590 题目答案:官方Editorial.My Solution A. Equalize Prices Again 签到题还WA了一发,向上取整有点问题: //my wrong code, 1.0 * sum返回double ceil(1.0 * sum / n); //right code (int)ceil(1.0 * sum / n); //ceil()原型 double ceil(double x); float能保证6位精度(有效数字),double能保证15位…