Codeforces 892 D.Gluttony】的更多相关文章

D. Gluttony time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output You are given an array a with n distinct integers. Construct an array b by permuting a such that for every non-empty subset of i…
题目链接:https://cn.vjudge.net/problem/CodeForces-892A Jafar has n cans of cola. Each can is described by two integers: remaining volume of cola ai and can's capacity bi (ai  ≤  bi). Jafar has decided to pour all remaining cola into just 2 cans, determin…
C. Pride time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output You have an array a with length n, you can perform operations. Each operation is like this: choose two adjacent elements from a, sa…
B. Wrath time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Hands that shed innocent blood! There are n guilty people in a line, the i-th of them holds a claw with length Li. The bell rings a…
A. Greed time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Jafar has n cans of cola. Each can is described by two integers: remaining volume of cola ai and can's capacity bi (ai  ≤  bi). Jaf…
A  链接:http://codeforces.com/problemset/problem/892/A 签到 #include <iostream> #include <algorithm> using namespace std; ]; int main() { int n; ,sum2=; cin>>n; ; i<n; ++i) cin>>a,sum1+=a; ; i<n; ++i) cin>>b[i]; sort(b,b+n)…
891B - Gluttony 题意 给出一个数字集合 \(a\),要求构造一个数组 \(b\) 为 \(a\) 的某个排列,且满足对于所有下标集合的子集 \(S=\{x_1,x_2,...,x_k\}(1\leq x_i \leq n, 0 < k < n)\),有 \(\sum_{i=1}^{k}a_{x_i}\neq\sum_{i=1}^{k}b_{x_i}\). 分析 不得不说,当我看到 \(n\) 只有 \(22\) 之后就跑偏了. 对于原数组中的每个数,可以直接确定它在新数组中对应…
题面: You are given an array a with n distinct integers. Construct an array b by permuting a such that for every non-empty subset of indices S = {x1, x2, ..., xk} (1 ≤ xi ≤ n, 0 < k < n) the sums of elements on that positions in a and b are different,…
C. Pride 传送门:http://codeforces.com/contest/892/problem/C 本题是一个关于序列的数学问题——最大公约数(GCD). 对于一个长度为n的序列A={a[i]|i=1,2,...,n},有以下操作:选定序列中的两个相邻元素,记为x和y,将其中一个替换成gcd(x,y).这个序列是否可以在有限步操作后,变成一个所有元素均为1的序列?若可行,则求最小操作步数:否则返回-1. 首先考虑可行性:若gcd{a[i]|i=1,2,...,n}=1,则可行:否则…
http://codeforces.com/contest/892/problem/D D. Gluttony You are given an array a with n distinct integers. Construct an array b by permuting a such that for every non-empty subset of indices S = {x1, x2, ..., xk} (1 ≤ xi ≤ n, 0 < k < n) the sums of…