[CodeForces 1249A --- Yet Another Dividing into Teams] Description You are a coach of a group consisting of n students. The i-th student has programming skill ai. All students have distinct programming skills. You want to divide them into teams in su…
B. Teams Formation link http://codeforces.com/contest/878/problem/B describe This time the Berland Team Olympiad in Informatics is held in a remote city that can only be reached by one small bus. Bus has n passenger seats, seat i can be occupied only…
B. Alice, Bob, Two Teams time limit per test 1.5 seconds memory limit per test 256 megabytes input standard input output standard output Alice and Bob are playing a game. The game involves splitting up game pieces into two teams. There are n pieces,…
题面 洛谷传送门 题解 博客 有精度要求所以只用求几十次就差不多了 CODE #include <bits/stdc++.h> using namespace std; typedef long long LL; const int MAXN = 300005; struct node { int v, id; inline bool operator <(const node &o)const { return v < o.v || (v == o.v &&…
A - Yet Another Dividing into Teams 题意:n个不同数,分尽可能少的组,要求组内没有两个人的差恰为1. 题解:奇偶分组. int a[200005]; void test_case() { int n; scanf("%d", &n); for(int i = 1; i <= n; ++i) scanf("%d", &a[i]); sort(a + 1, a + 1 + n); int ans = 1; for…
题目传送门 A .Yet Another Dividing into Teams sol:原先是用比较复杂的方法来解的,后来学弟看了一眼,发现不是1就是2,当出现两个人水平相差为1就分成两组,1组全是奇数,1组全是偶数,必然符合题意. 思维 #include "bits/stdc++.h" using namespace std; #define debug puts("what the fuck"); typedef long long LL; typedef p…
A. Splitting in Teams time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output There were n groups of students which came to write a training contest. A group is either one person who can write the…
codeforces   478B  Random Teams  解题报告 题目链接:cm.hust.edu.cn/vjudge/contest/view.action?cid=88890#problem/B 题目: Description n participants of the competition were split into m teams in some manner so that each team has at least one participant. After th…
D. Dividing Kingdom II 题目连接: http://www.codeforces.com/contest/687/problem/D Description Long time ago, there was a great kingdom and it was being ruled by The Great Arya and Pari The Great. These two had some problems about the numbers they like, so…
E. Two Teams time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output There are nn students standing in a row. Two coaches are forming two teams — the first coach chooses the first team and the sec…
http://codeforces.com/contest/1092/problem/B There are nn students in a university. The number of students is even. The ii-th student has programming skill equal to aiai. The coach wants to form n2n2 teams. Each team should consist of exactly two stu…
B. Alice, Bob, Two Teams 题目连接: http://www.codeforces.com/contest/632/problem/B Description Alice and Bob are playing a game. The game involves splitting up game pieces into two teams. There are n pieces, and the i-th piece has a strength pi. The way…
http://codeforces.com/contest/478/problem/B B. Random Teams time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output n participants of the competition were split into m teams in some manner so that…
Codeforces Round #598 (Div. 3)- E. Yet Another Division Into Teams - 动态规划 [Problem Description] 给你\(n\)个数,将其划分为多组,对于每个组定义其\(d\)值为 组内的最大值减最小值,问如何划分使得最终所有组的\(d\)值之和最小.每个组至少要保证有\(3\)个数. [Solution] 将所有值从小到大排序,然后我们知道最多有\(5\)个人划分到同一组中,如果有\(6\)个人,那么划分为两组一定比…
题目链接:http://codeforces.com/problemset/problem/478/B 题目意思:有 n 个人,需要将这班人分成 m 个 组,每个组至少含有一个人,同一个组里的人两两可以结交成一个pair,问怎样分配,可以使得 pair 数最少和最多,输出之. 首先最多 pair 数是很容易求出的,就是 m-1 个组里都放 1 个人,然后最后那个组(即第 m组)人数最多,pair数自然最多,答案就是 (n-m+1) * (n-m) / 2. 最少 pair 数,做的时候有一点点思…
D. Dividing Kingdom II   Long time ago, there was a great kingdom and it was being ruled by The Great Arya and Pari The Great. These two had some problems about the numbers they like, so they decided to divide the great kingdom between themselves. Th…
B. Fox Dividing Cheese time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Two little greedy bears have found two pieces of cheese in the forest of weight a and b grams, correspondingly. The be…
题目: You are a coach at your local university. There are nn students under your supervision, the programming skill of the ii-th student is aiai. You have to form kk teams for yet another new programming competition. As you know, the more students are…
题目链接:https://codeforces.com/contest/1154/problem/E 题意: $n$ 个人排成一排,第 $i$ 个人的能力值为 $a[i]$,$a[1 \sim n]$ 是 $1 \sim n$ 的某个排列. 第一个教练先来拉人,他会拉目前还在队伍中的 $a[i]$ 最高的那个人,并且把排在它前面和后面的各自 $k$ 个人都拉走,即最多可以拉走 $2k + 1$ 个人. 然后,第二个教练来拉人,也是同样的操作.注意,如果当前被拉走的人的前面或者后面不足 $k$ 个…
题目链接:http://codeforces.com/problemset/problem/1154/E 题目大意: 有n个队员,编号1~n,每个人的能力各自对应1~n中的一个数,每个人的能力都不相同.有1号教练和2号教练,他们轮流从剩余队伍里选人,轮到某位教练选时,它总是选剩余队员中能力最强的人和他左右各k个人.问选完的时候每个人的组号. 分析: 什么结构能快速查找到队员呢?当然是数组啦!什么结构能频繁删改呢?当然是链表啦!所以就用承载在数组上的链表来做啦! 代码如下: #pragma GCC…
B. Random Teams time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output n participants of the competition were split into m teams in some manner so that each team has at least one participant. Afte…
C. Dividing the numbers Petya has n integers: 1, 2, 3, ..., n. He wants to split these integers in two non-empty groups in such a way that the absolute difference of sums of integers in each group is as small as possible. Help Petya to split the inte…
题目链接:http://codeforces.com/contest/1133/problem/E 题目大意: 在n个人中找到k个队伍.每个队伍必须满足最大值减最小值不超过5.求满足条件k个队伍人数的总和的最大值. 这个题写DP很多的人应该可以很快写出来吧,毕竟不是很难. 思路: 反正最多n^2种状态.用数组存就好了. 先排序. 对于每个点,dp[a][b].表示a到n区间里分b个队伍的答案. 如果a是答案dp[a][b]所需要的,那么我们从a开始到a+i暴力一下(此时,x[a+i]-x[a]>…
B. Random Teams time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output n participants of the competition were split into m teams in some manner so that each team has at least one participant. Afte…
  C. Dividing the numbers   time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Petya has n integers: 1, 2, 3, ..., n. He wants to split these integers in two non-empty groups in such a way tha…
  A. Splitting in Teams   time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output There were n groups of students which came to write a training contest. A group is either one person who can write…
题目链接 Fox Dividing Cheese 思路:求出两个数a和b的最大公约数g,然后求出a/g,b/g,分别记为c和d. 然后考虑c和d,若c或d中存在不为2,3,5的质因子,则直接输出-1(根据题目要求) 计算出c = (2 ^ a2) * (3 ^ a3) * (5 ^ a5)      d = (2 ^ b2) * (3 ^ b3) * (5 ^ b5) 那么答案就是a2 + a3 + a5 + b2 + b3 + b5 #include <bits/stdc++.h> usin…
time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output There are nn students in a university. The number of students is even. The ii-th student has programming skill equal to aiai. The coach wants…
B. Random Teams   n participants of the competition were split into m teams in some manner so that each team has at least one participant. After the competition each pair of participants from the same team became friends. Your task is to write a prog…
传送门:http://codeforces.com/contest/899/problem/C 本题是一个数学问题——集合划分. 将集合{1,2,...,n}划分成两个集合,使得两个集合的元素之和的绝对差值最小. 首先,考虑最简单的操作: 第1步:将元素1和n置入集合A: 第2步:将元素2和n-1置入集合B: 第3步:将元素3和n-2置入集合A: …… 第i步:将元素i和n+1-i,当i为奇数时置入集合A,偶数时置入集合B: …… 第n/2步:将元素n/2和n/2+1置入集合B. 如此,集合A中…