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\) ...
随机推荐
- [转帖]linux Shell sort按照指定列排序
linux Shell sort按照指定列排序 https://blog.csdn.net/weixin_38308151/article/details/80760133 kubectl get p ...
- CF1051D Bicolorings
题目描述 咳咳,懒得复制了上面是两张图:) 解题思路 这题是一道很好的题,感觉之前做过,一开始手推状态找规律,可以用状压但是没想到 借鉴了一下大佬的dp modify数组用以累加新增的状态数 dp数组 ...
- 我在LeetCode的首次刷题
到现在为止,我才发现我的博客一篇感受,心得,体会之言都没有. 今天就来随便扯扯. 刷题,是我最近一直在干的事情.也就每天写一两个.忘了就没写这种.也收藏了好几个刷题网站,当然第一次接触肯定是 WUST ...
- array_merge_recursive 的使用
作用:递归合并数组 场景:在平时开发中,我们可能遇到获取的数据是多个维度的数据,而我们只需要其中的一个. 代码如下: $project_id = 'project_id'; $arr1 = [ 'pr ...
- rsync 使用
rsync命令是一个远程数据同步工具,可通过LAN/WAN快速同步多台主机间的文件. rsync使用所谓的“rsync算法”来使本地和远程两个主机之间的文件达到同步,这个算法只传送两个文件的不同部分, ...
- go 学习笔记(4) --变量与常量
“_” 可以理解成一个垃圾桶,我们把值赋给“_” ,相当于把值丢进垃圾桶,在接下来的程序中运行中不需要这个下划线这个值 a,b :=1,2 只能用在函数体内 package main impor ...
- Linux 系统中如何进入退出 vim 编辑器
在 Linux 中,vim 编辑器是系统自带的文本编辑器,但要修改某个文本文件,可不是像 Windows 那样操作,更有新手,进入 vi 编辑器后,无法退出以致于强制关机,其实,这个vim(vi)也是 ...
- bat计算指定文件MD5并输出txt
@echo off set Name1=*.ADS set Name2=GM_RSSPI* set Name3=equipment* set Name4=protocols* REM 设置输出文件名 ...
- 页面 ajax
function ajax({ url, success, data = { }, type= "GET", async = true}){ let xhr; if(XMLHttp ...
- js(es6)数组去重
// 利用set.reduce.filter去重 // Set function getSetArr(arr) { return [...new Set(arr)] } console.log(get ...