链接:

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. KAFA优点和缺点

    我们上一期的Kafka教程中,我们讨论了Kafka的Books.今天,我们将讨论卡夫卡的优势和劣势.因为,在使用之前了解任何技术的局限性非常重要,在优点的情况下也是如此.所以,让我们详细讨论卡夫卡优势 ...

  2. 长乐培训Day4

    T1 矩阵 题目 [题目描述] 从前有个 n×m 的矩阵,初始时每个位置均为 0.你需要依次执行 q 个操作,每个操作会指定一行或一列,然后将该行或该列的所有元素全部赋为一个相同的值. 输出操作完成后 ...

  3. Django django.core.exceptions.ImproperlyConfigured: WSGI application 'myblog.wsgi.application' could not be loaded; Error importing module.报错

    报错内容 django.core.exceptions.ImproperlyConfigured: WSGI application 'myblog.wsgi.application' could n ...

  4. python基础 — 数据组合

    a = [1, 2, 3] b = [4, 5, 6] c = [7, 8, 9] for x, y, z in (a, b, c): print(x, y, x) print(type(zip(a, ...

  5. Vue.js 2.x render 渲染函数 & JSX

    Vue.js 2.x render 渲染函数 & JSX Vue绝大多数情况下使用template创建 HTML.但是比如一些重复性比较高的场景,需要运用 JavaScript 的完全编程能力 ...

  6. L2R 一:基础知识介绍

    一.背景 l2r可以说是搜索推荐里面很常用的知识了,一直处于一知半解的地步,今天开个博客准备把这些零散的东西系统性整理好,一版就粗糙点了. 二.粗概 前段时间的项目主要和搜索引擎相关,记录下搜索引擎的 ...

  7. PB 计算公式算出结果赋值给另外一列

    在数据窗口中添加一个公式列 --在itmchanged事件中写的计算赋值代码 String ls_gs,ls_sqldecimal{2} ls_gsjg if dwo.name='gs1' then ...

  8. mysql疑问

  9. LOJ2074/2157 JSOI2016/POI2011 Lightning Conductor 决策单调性DP

    传送门 我们相当于要求出\(f_i = \max\limits_{j=1}^{n} (a_j + \sqrt{|i-j|})\).这个绝对值太烦人了,考虑对于\(i>j\)和\(i<j\) ...

  10. caffe基础入门

    学的太浅,先放一个别人写的吧,等自己摸清楚回来搞搞. https://blog.csdn.net/cham_3/article/details/72141753