用前缀和写一直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 ;
}

最新文章

  1. ExecuteReader在执行有输出参数的存储过程时拿不到输出参数
  2. 网页中多个图标在一张图片上,使用css将各图标显示
  3. Eclipse 打不开
  4. 牛顿法与拟牛顿法学习笔记(五)L-BFGS 算法
  5. spring 获取 bean
  6. LCLFramework框架 1.1 Pre-Alpha 源码公布
  7. Linux复制指定目录下的文件夹结构
  8. VC++中 wstring和string的互相转换实现
  9. css 冷门样式大全
  10. MIT-线性代数笔记(1-6)
  11. redux middleware 源码分析
  12. 利用Eclipse中的Maven构建Web项目报错(二)
  13. zTree实现删除树子节点
  14. CentOS 7 安装MySQL 5.6遇到问题及解决方案
  15. appium 与 selenium python解决python &#39;WebElement&#39; object does not support indexing 报错问题问题
  16. 云计算openstack共享组件(3)——消息队列rabbitmq
  17. Linux anaconda 内网 安装 卸载
  18. 【Eclipse】将Tab替换为空格
  19. P1858 多人背包
  20. m4, autoconf

热门文章

  1. ASP.NET动态网站课程设计——个人网页
  2. 【Java】 NullPointerException、ArrayIndexOutOfBoundsException、ClassCastException、ArrayIndexOutOfBoundsException、ArrayStoreException、ArithmeticException等没有异常堆栈信息
  3. coding++:thymelef 模板报错 the entity name must immediately follow the &#39;&amp;&#39; in the entity reference
  4. coding++ :HttpClientUtils 封装
  5. 模块 face_recognition 人脸识别
  6. JS 剑指Offer(四) 从尾到头打印链表
  7. yum-程序包管理器前端工具
  8. Python数据库MySQL之数据备份、pymysql模块
  9. python:列表切片知识的总结
  10. 1053 Path of Equal Weight (30分)(并查集)