Codeforces Round #604 (Div. 2) C. Beautiful Regional Contest
链接:
https://codeforces.com/contest/1265/problem/C
题意:
So the Beautiful Regional Contest (BeRC) has come to an end! n students took part in the contest. The final standings are already known: the participant in the i-th place solved pi problems. Since the participants are primarily sorted by the number of solved problems, then p1≥p2≥⋯≥pn.
Help the jury distribute the gold, silver and bronze medals. Let their numbers be g, s and b, respectively. Here is a list of requirements from the rules, which all must be satisfied:
for each of the three types of medals, at least one medal must be awarded (that is, g>0, s>0 and b>0);
the number of gold medals must be strictly less than the number of silver and the number of bronze (that is, g<s and g<b, but there are no requirements between s and b);
each gold medalist must solve strictly more problems than any awarded with a silver medal;
each silver medalist must solve strictly more problems than any awarded a bronze medal;
each bronze medalist must solve strictly more problems than any participant not awarded a medal;
the total number of medalists g+s+b should not exceed half of all participants (for example, if n=21, then you can award a maximum of 10 participants, and if n=26, then you can award a maximum of 13 participants).
The jury wants to reward with medals the total maximal number participants (i.e. to maximize g+s+b) so that all of the items listed above are fulfilled. Help the jury find such a way to award medals.
思路:
直接找到不相等的位置,满足条件即可。
代码:
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 4e5+10;
int a[MAXN];
int n;
int main()
{
// freopen("test.in", "r", stdin);
ios::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
int t;
cin >> t;
while(t--)
{
bool flag = true;
cin >> n;
for (int i = 1;i <= n;i++)
cin >> a[i];
int i = 2;
for (i = 2;i <= n;i++)
{
if (a[i] != a[i-1])
break;
}
int m = n/2;
if ((m-(i-1))/2 <= (i-1))
flag = false;
int j;
for (j = m;j >= i;j--)
{
if (a[j] > a[j+1])
break;
}
int k = -1;
for (int ii = i+1;ii <= j;ii++)
{
if (a[ii] < a[ii-1] && ii-i > i-1)
{
k = ii;
break;
}
}
if (k == -1)
flag = false;
if (i-1 >= k-i || i-1 >= j-k+1)
flag = false;
if (!flag)
cout << "0 0 0" << endl;
else
cout << i-1 << ' ' << k-i << ' ' << j-k+1 << endl;
}
return 0;
}
Codeforces Round #604 (Div. 2) C. Beautiful Regional Contest的更多相关文章
- Codeforces Round #604 (Div. 2) C. Beautiful Regional Contest(贪心)
题目链接:https://codeforces.com/contest/1265/problem/C 题意 从大到小给出 $n$ 只队伍的过题数,要颁发 $g$ 枚金牌,$s$ 枚银牌,$b$ 枚铜牌 ...
- Codeforces Round #604 (Div. 2) E. Beautiful Mirrors
链接: https://codeforces.com/contest/1265/problem/E 题意: Creatnx has n mirrors, numbered from 1 to n. E ...
- Codeforces Round #604 (Div. 2) D. Beautiful Sequence(构造)
链接: https://codeforces.com/contest/1265/problem/D 题意: An integer sequence is called beautiful if the ...
- Codeforces Round #604 (Div. 2) B. Beautiful Numbers
链接: https://codeforces.com/contest/1265/problem/B 题意: You are given a permutation p=[p1,p2,-,pn] of ...
- Codeforces Round #604 (Div. 2) A. Beautiful String
链接: https://codeforces.com/contest/1265/problem/A 题意: A string is called beautiful if no two consecu ...
- Codeforces Round #604 (Div. 2) E. Beautiful Mirrors 题解 组合数学
题目链接:https://codeforces.com/contest/1265/problem/E 题目大意: 有 \(n\) 个步骤,第 \(i\) 个步骤成功的概率是 \(P_i\) ,每一步只 ...
- Codeforces Round #604 (Div. 2) A. Beautiful String(贪心)
题目链接:https://codeforces.com/contest/1265/problem/A 题意 给出一个由 a, b, c, ? 组成的字符串,将 ? 替换为 a, b, c 中的一个字母 ...
- Codeforces Round #604 (Div. 2) B. Beautiful Numbers(双指针)
题目链接:https://codeforces.com/contest/1265/problem/B 题意 给出大小为 $n$ 的一个排列,问对于每个 $i(1 \le i \le n)$,原排列中是 ...
- Codeforces Round #604 (Div. 1) - 1C - Beautiful Mirrors with queries
题意 给出排成一列的 \(n\) 个格子,你要从 \(1\) 号格子走到 \(n\) 号格子之后(相当于 \(n+1\) 号格子),一旦你走到 \(i+1\) 号格子,游戏结束. 当你在 \(i\) ...
随机推荐
- 13 IO流(十)——BufferedReader/BufferedWriter 装饰流
Buffered字符包装流 与Buffered字节装饰流一样,只不过是对字符流进行包装. 需要注意的地方 Buffered字符流在Reader与Writer上有两个新的方法:String readLi ...
- 『Go基础』第8节 格式化输出
输出就是将数据信息打印到电脑屏幕上. 本节我们就来学习一下Go语言中的三种输出方式: Print().Println().Printf(). 1.Print() Print()主要的一个特点就是打印数 ...
- SAS学习笔记58 单元格格式化设计
单元格行_row_ 对于行单元格,主要就通过_row_这么一个自动变量的方式,来对单元格所有行进行格式化设计 例如,对性别为“男”的单元格所在行颜色设定为红色: 单元格列_col_ 将_row_改成_ ...
- Luogu4233 射命丸文的笔记 DP、多项式求逆
传送门 注意到总共有\(\frac{n!}{n}\)条本质不同的哈密顿回路,每一条哈密顿回路恰好会出现在\(2^{\binom{n}{2} - n}\)个图中,所以我们实际上要算的是强连通有向竞赛图的 ...
- 转:JVM的符号引用和直接引用
在JVM中类加载过程中,在解析阶段,Java虚拟机会把类的二级制数据中的符号引用替换为直接引用. 1.符号引用(Symbolic References): 符号引用以一组符号来描述所引用的目标,符号可 ...
- Java Web 深入分析(11) JVM(1)
前言 Java启动后作为一个进程运行在操作系统中,该进程要分配的内存有以下几个: 1.Java堆: 存储java内存区域,堆大小是在jvm启动时就像操作系统申请完成,其中 -Xmx和-Xms 分别表示 ...
- MySQL分库备份
1.需求概述 每天00:00备份MySQL数据库数据: 每一个库生成一个文件,使用gzip压缩,文件名:backup_库名_yyyymmdd.sql.gz,注意yyyymmdd需要是前一天: 备份文件 ...
- 快速精通Mac效率神器Alfred以及常用workflow
概述 Alfred基础在上一篇 大纲 名称 作用 类别 出处 修改日期 Github 更便捷地使用Github 开发编程 Github 2017-01-28 Github Search Github搜 ...
- javascript原型链[图]
- Linux expect实现自动登录
expect expect可以让我们实现自动登录远程机器,并且可以实现自动远程执行命令.当然若是使用不带密码的密钥验证同样可以实现自动登录和自动远程执行命令.但当不能使用密钥验证的时候,我们就没有办法 ...