Codeforces 1154B Make Them Equal 题目链接:http://codeforces.com/problemset/problem/1154/B 题意:给定数组,可以给任意的的元素加上D 或者 减去D,如果能 使数组元素都相等,输出最小的D,不能输出-1。 思路:若要相等,唯有种类数小于3的才可以。 AC代码: 1#include<bits/stdc++.h>2usingnamespacestd;3int...
1/**\2 https://codeforces.com/problemset/problem/1633/D3 注意到b[i]的范围最大是 1000 ,从1-1000 变化最多大约在13次左右4 13n复杂度不高,直接预处理每个数从1-1000变化花费5 然后经典01背包6 \**/7#include<bits/stdc++.h>8usingnamespacestd;9#defineint long long10#definesf(x) scanf("...
CodeForces673 Div.2 D - Make Them Equal 思维,构造 题意 给定正数数组$a$,长度为$n$。 要求在$3n$次操作内使数组的值都相等。 操作描述如下: 任何操作结束后必须保证所有元素非负 \[ 1.选择i,j,x.其中1\leq i \leq j\leq n.
Codeforces Round 673 (Div. 1) B. Make Them Equal bhdtr Warframe高手 3 人赞同了该文章 Problem - B - Codeforcescodeforces.com/contest/1416/problem/B 好巧妙的做法。 题意: 给定一个长度为 n 的数组,第 i 个数的大小为 a[i],每次操作你可以选定 i, j, x 使得,a[i] = a[i] - i ...
#include<bits/stdc++.h> using namespace std; const int maxn=1e5+10; int a[maxn]; struct node{ int a,b,x; }; vector<node>ans; void f(int x,int y,int z){ a[x]-=x*z; a[y]+=x*z; ans.push_back({x,y,z}); } void solve(){ int n,sum=0;cin>>n; for(int i=1...
D - Make Them Equal https://codeforces.com/contest/1633/problem/D #include<bits/stdc++.h> using namespace std; #define int long long const int mod = 1e9 + 7; const int N= 1e6 + 10; int n, k; int b[N], c[N], v[N];...
B. Make Them Equal time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output You are given a sequence a1,a2,…,an consisting of n integers. You can choose any non-negative integer D (i.e. D≥0), and for each ai you can: ...
1154B-MakeThemEqual.cpp 1154C-GourmetCat.cpp 1154D-WalkingRobot.cpp 1154E-TwoTeams.cpp 1155A-ReverseAString.cpp 1155B-GameWithTelephoneNumbers.cpp 1155C-AlarmClocksEverywhere.cpp 1156A-InscribedFigures.cpp 1156B-UglyPairs.cpp 1157A-ReachableNumbers.cpp 1157B-LongNumber.cpp 1157C1-IncreasingSubseque...
the arraya1,a2,…,ana_1, a_2, \dots, a_na1,a2,…,ancontainsexactly222distinct values at the end of the operation. It can be shown that, under the constraints of the problem, at least one suchkkkalways exists. If there are multiple solutions, you can print any of them....
CodeForces Algorithms. Contribute to m-aprameya/CodeForces development by creating an account on GitHub.