A. Salem and Sticks time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Salem gave you nn sticks with integer positive lengths a1,a2,…,ana1,a2,…,an. For every stick, you can change its length t…
链接:https://codeforces.com/contest/1105/problem/A 题意: 给n个数,找到一个数t使i(1-n)∑|ai-t| 最小. ai-t 差距1 以内都满足 思路: 暴力,枚举. 代码: #include <bits/stdc++.h> using namespace std; typedef long long LL; const int MAXN = 1000+5; int a[MAXN]; int main() { int n; scanf(&quo…
#include <bits/stdc++.h> using namespace std; int main() { int n;cin>>n; int a[n];for(int &i:a) cin>>i; int ans_ave=0,ans_cost=INT_MAX; for(int i=1;i<=100;i++){ int ave=i,cost=0; for(int j:a){ if(j<i) cost+=i-1-j; else if(j>…
link orz olinr AK Codeforces Round #533 (Div. 2) 中文水平和英文水平都太渣..翻译不准确见谅 T1.给定n<=1000个整数,你需要钦定一个值t,使得每个整数到线段[t-1,t+1]距离和最小,求最小距离,每个数<=100 枚举t #include <cstdio> using namespace std; int n, a[1010]; int main() { scanf("%d", &n); for…
Codeforces Round #297 (Div. 2)C. Ilya and Sticks Time Limit: 2 Sec  Memory Limit: 256 MBSubmit: xxx  Solved: 2xx 题目连接 http://codeforces.com/contest/525/problem/C Description In the evening, after the contest Ilya was bored, and he really felt like ma…
题目传送门 /* 题意:给n个棍子,组成的矩形面积和最大,每根棍子可以-1 贪心:排序后,相邻的进行比较,若可以读入x[p++],然后两两相乘相加就可以了 */ #include <cstdio> #include <algorithm> #include <cstring> #include <cmath> using namespace std; typedef long long ll; ; const int INF = 0x3f3f3f3f; in…
A. Salem and Sticks 签. #include <bits/stdc++.h> using namespace std; #define N 1010 int n, a[N]; int work(int x) { ; ; i <= n; ++i) res += max(, abs(x - a[i]) - ); return res; } int main() { while (scanf("%d", &n) != EOF) { ; i <…
A. Salem and Sticks 题目描述 Salem gave you n n n sticks with integer positive lengths a1,a2,…,an a_1, a_2, \ldots, a_n a1​,a2​,…,an​ . For every stick, you can change its length to any other positive integer length (that is, either shrink or stretch it)…
题目链接:https://codeforces.com/contest/1105 C. Ayoub and Lost Array 题目大意:一个长度为n的数组,数组的元素都在[L,R]之间,并且数组全部元素的和可以被3整除,问有多少种方法构建出该数组.答案模1000000007 例 输入 2 1 3 输出 3 note:满足的情况只有[1,2],[2,1],[3,3] 解题思路:用dp[i][j]表示长度为i的数组,元素大小在[L,R]之间,并且元素和模3的余数为j的方案数,我们可以计算出[L,…
传送门:http://codeforces.com/contest/1105/problem/C C. Ayoub and Lost Array time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Ayoub had an array aa of integers of size nn and this array had two…