链接:

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的更多相关文章

  1. Codeforces Round #604 (Div. 2) C. Beautiful Regional Contest(贪心)

    题目链接:https://codeforces.com/contest/1265/problem/C 题意 从大到小给出 $n$ 只队伍的过题数,要颁发 $g$ 枚金牌,$s$ 枚银牌,$b$ 枚铜牌 ...

  2. 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 ...

  3. Codeforces Round #604 (Div. 2) D. Beautiful Sequence(构造)

    链接: https://codeforces.com/contest/1265/problem/D 题意: An integer sequence is called beautiful if the ...

  4. 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 ...

  5. Codeforces Round #604 (Div. 2) A. Beautiful String

    链接: https://codeforces.com/contest/1265/problem/A 题意: A string is called beautiful if no two consecu ...

  6. Codeforces Round #604 (Div. 2) E. Beautiful Mirrors 题解 组合数学

    题目链接:https://codeforces.com/contest/1265/problem/E 题目大意: 有 \(n\) 个步骤,第 \(i\) 个步骤成功的概率是 \(P_i\) ,每一步只 ...

  7. Codeforces Round #604 (Div. 2) A. Beautiful String(贪心)

    题目链接:https://codeforces.com/contest/1265/problem/A 题意 给出一个由 a, b, c, ? 组成的字符串,将 ? 替换为 a, b, c 中的一个字母 ...

  8. Codeforces Round #604 (Div. 2) B. Beautiful Numbers(双指针)

    题目链接:https://codeforces.com/contest/1265/problem/B 题意 给出大小为 $n$ 的一个排列,问对于每个 $i(1 \le i \le n)$,原排列中是 ...

  9. Codeforces Round #604 (Div. 1) - 1C - Beautiful Mirrors with queries

    题意 给出排成一列的 \(n\) 个格子,你要从 \(1\) 号格子走到 \(n\) 号格子之后(相当于 \(n+1\) 号格子),一旦你走到 \(i+1\) 号格子,游戏结束. 当你在 \(i\) ...

随机推荐

  1. [转帖]armel、armhf和arm64

    armel.armhf和arm64 转帖 1 这些名词是什么的缩写 1.1 armel 是arm eabi little endian的缩写.eabi是软浮点二进制接口,这里的e是embeded,是对 ...

  2. tkinter学习笔记_06

    12.弹窗 messagebox import tkinter as tk from tkinter import messagebox root = tk.Tk() root.title(" ...

  3. 长连接、短连接、长轮询和WebSocket

    //转发,格式待整理 2017-08-0519784View0 对这四个概念不太清楚,今天专门搜索了解一下,总结一下: 长连接:在HTTP 1.1,客户端发出请求,服务端接收请求,双方建立连接,在服务 ...

  4. consul安装配置,生产环境部署高可用环境

    1.建立三个consul节点(一个server+两个client) 具体的过程见http://www.cnblogs.com/java-zhao/p/5375132.html 1)在终端下启动vagr ...

  5. node-red File读取好保存

    File节点是操作文件的节点 file文件的保存 拖拽 注入节点inject  file节点(writes msg.payload to a file)和 debug节点到工作区,并连线 设置file ...

  6. [winfrom]C#中使用SendMessage

    在C#中,程序采用了的驱动采用了事件驱动而不是原来的消息驱动,虽然.net框架提供的事件已经十分丰富,但是在以前的系统中定义了丰富的消息对系统的编程提供了方便的实现方法,因此在C#中使用消息有时候还是 ...

  7. centOS学习part7:Oracle开机自启配置

    0 上一章(http://www.cnblogs.com/souvenir/p/3884904.html)我们用了很多时间以及很长的篇幅来介绍oracle的整个安装过程,希望对大家用所帮助.oracl ...

  8. [daily] ssh通过私钥导出公钥

    在使用key方式登录ssh服务的时候,我们知道ssh key是使用公钥ssh-keygen工具生成的. 有时候,我们只保存了私钥,但是并没有保存公钥.这个时候,可以使用如下方法,   从私钥中将公钥导 ...

  9. Linux命令——lspci

    参考:7 Linux lspci Command Examples to Get PCI Bus Hardware Device Info 简介 lspci可以看成“ls” + “pci”.lspci ...

  10. Ubuntu 18.04 使用apt-get 华为源支持 arm64 鲲鹏处理器

    网上搜的源,什么阿里云163等等的,都不支持arm64 执行以下代码,使用华为源 wget -O /etc/apt/sources.list https://repo.huaweicloud.com/ ...