C. Beautiful Regional Contest
2024-09-07 10:27:38
用前缀和写一直wa。。
思路:让金牌和银牌最少,通多增加铜牌的方式来扩大总奖牌的个数。
#include<bits/stdc++.h>
using namespace std;
map<int ,int >mp;
const int N=1e6+;
int arr[N];
void solve()
{
mp.clear();
int n;
cin>>n;
int x;
int pos=;
for(int i=;i<=n;i++){
cin>>x;
if(!mp[x]) arr[pos++]=x;
mp[x]++;
}
if(pos<) {
cout<<"0 0 0"<<endl;
return ;
}
int m=n/;
if(m<) {
cout<<"0 0 0"<<endl;
return ;
}
int g=mp[arr[]];
int b=,c=,posb,posc;
int ansb=;
for(int i=;i<pos;i++){
ansb+=mp[arr[i]];
if(ansb>g){
b=ansb;
posb=i;
break;
}
}
if(b==){
cout<<"0 0 0"<<endl;
return ;
}
int ansc=;
for(int i=posb+;i<pos;i++){
ansc+=mp[arr[i]];
if(ansc>g){
c=ansc;
posc=i;
break;
}
}
if(c==){
cout<<"0 0 0"<<endl;
return ;
}
if(g+c+b>n/){
cout<<"0 0 0"<<endl;
return ;
}
while(g+b+c<=n/){
c+=mp[arr[++posc]];
}
c-=mp[arr[posc]];
cout<<g<<" "<<b<<" "<<c<<endl;
} int main()
{
ios::sync_with_stdio();
int t;
cin>>t;
while(t--) solve();
return ;
}
最新文章
- ExecuteReader在执行有输出参数的存储过程时拿不到输出参数
- 网页中多个图标在一张图片上,使用css将各图标显示
- Eclipse 打不开
- 牛顿法与拟牛顿法学习笔记(五)L-BFGS 算法
- spring 获取 bean
- LCLFramework框架 1.1 Pre-Alpha 源码公布
- Linux复制指定目录下的文件夹结构
- VC++中 wstring和string的互相转换实现
- css 冷门样式大全
- MIT-线性代数笔记(1-6)
- redux middleware 源码分析
- 利用Eclipse中的Maven构建Web项目报错(二)
- zTree实现删除树子节点
- CentOS 7 安装MySQL 5.6遇到问题及解决方案
- appium 与 selenium python解决python &#39;WebElement&#39; object does not support indexing 报错问题问题
- 云计算openstack共享组件(3)——消息队列rabbitmq
- Linux anaconda 内网 安装 卸载
- 【Eclipse】将Tab替换为空格
- P1858 多人背包
- m4, autoconf
热门文章
- ASP.NET动态网站课程设计——个人网页
- 【Java】 NullPointerException、ArrayIndexOutOfBoundsException、ClassCastException、ArrayIndexOutOfBoundsException、ArrayStoreException、ArithmeticException等没有异常堆栈信息
- coding++:thymelef 模板报错 the entity name must immediately follow the &#39;&;&#39; in the entity reference
- coding++ :HttpClientUtils 封装
- 模块 face_recognition 人脸识别
- JS 剑指Offer(四) 从尾到头打印链表
- yum-程序包管理器前端工具
- Python数据库MySQL之数据备份、pymysql模块
- python:列表切片知识的总结
- 1053 Path of Equal Weight (30分)(并查集)