Codeforces Round #351 (VK Cup 2016 Round 3, Div. 2 Edition) C - Bear and Colors
题目链接:
http://codeforces.com/contest/673/problem/C
题解:
枚举所有的区间,维护一下每种颜色出现的次数,记录一下出现最多且最小的就可以了。
暴力n*n.
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
using namespace std; const int maxn=;
const int INF=0x3f3f3f3f; int arr[maxn],ans[maxn],cnt[maxn]; int main() {
int n;
while(scanf("%d",&n)==&&n) {
memset(ans,,sizeof(ans));
for(int i=; i<=n; i++) {
scanf("%d",&arr[i]);
}
for(int st=;st<=n;st++){
memset(cnt,,sizeof(cnt));
int ma=-,tmp=INF;
for(int ed=st;ed<=n;ed++){
cnt[arr[ed]]++;
if(cnt[arr[ed]]>ma){
ma=cnt[arr[ed]]; tmp=arr[ed];
}else if(cnt[arr[ed]]==ma){
tmp=min(tmp,arr[ed]);
}
ans[tmp]++;
}
}
for(int i=;i<n;i++){
printf("%d ",ans[i]);
}
printf("%d\n",ans[n]);
}
return ;
}
Codeforces Round #351 (VK Cup 2016 Round 3, Div. 2 Edition) C - Bear and Colors的更多相关文章
- Codeforces Round #351 (VK Cup 2016 Round 3, Div. 2 Edition) C. Bear and Colors 暴力
C. Bear and Colors 题目连接: http://www.codeforces.com/contest/673/problem/C Description Bear Limak has ...
- Codeforces Round #351 (VK Cup 2016 Round 3, Div. 2 Edition) B. Problems for Round 水题
B. Problems for Round 题目连接: http://www.codeforces.com/contest/673/problem/B Description There are n ...
- Codeforces Round #351 (VK Cup 2016 Round 3, Div. 2 Edition) B
B. Problems for Round time limit per test 2 seconds memory limit per test 256 megabytes input standa ...
- Codeforces Round #351 (VK Cup 2016 Round 3, Div. 2 Edition)只有A题和B题
连接在这里,->点击<- A. Bear and Game time limit per test 2 seconds memory limit per test 256 megabyte ...
- Codeforces Round #351 (VK Cup 2016 Round 3, Div. 2 Edition) D Bear and Two Paths
题目链接: http://codeforces.com/contest/673/problem/D 题意: 给四个不同点a,b,c,d,求是否能构造出两条哈密顿通路,一条a到b,一条c到d. 题解: ...
- Codeforces Round #351 (VK Cup 2016 Round 3, Div. 2 Edition) D. Bear and Two Paths 构造
D. Bear and Two Paths 题目连接: http://www.codeforces.com/contest/673/problem/D Description Bearland has ...
- Codeforces Round #351 (VK Cup 2016 Round 3, Div. 2 Edition) A. Bear and Game 水题
A. Bear and Game 题目连接: http://www.codeforces.com/contest/673/problem/A Description Bear Limak likes ...
- Codeforces Round #351 (VK Cup 2016 Round 3, Div. 2 Edition)
A.暴力枚举,注意游戏最长为90分钟 B.暴力,c[l]++,c[r]--,记录中间有多长的段是大小为n的,注意特判m=0的情况 C.暴力枚举,我居然一开始没想出来!我一直以为每次都要统计最大的,就要 ...
- Codeforces Round #351 (VK Cup 2016 Round 3, Div. 2 Edition) D
D. Bear and Two Paths time limit per test 2 seconds memory limit per test 256 megabytes input standa ...
随机推荐
- js方法和原型继承(一)
在js语言规范中并不存在方法这一概念,方便起见,将作为对象属性的函数成为方法this引用的规则a.在最外层代码中,this引用的是全局对象b.在函数内,this引用根据函数调用方式不同而不同函数内部的 ...
- C# 多线程操作样例
using System; using System.Threading; //引用多线程 namespace ThreadTest { public class Alpha { public voi ...
- JDBC基础二
1.配置文件:dbinfo.properties driverClass=com.mysql.jdbc.Driver url=jdbc:mysql://127.0.0.1:3306/test user ...
- Python之Flask Web开发
下载python包管理工具Pip: 访问网址:https://pip.pypa.io/en/stable/installing/ 下载文件get-pip.py到本地计算机 定位到get-pip. ...
- ASP.NET 5概观 (ASP.NET 5 Overview)
http://www.asp.net/vnext/overview/aspnet-vnext/aspnet-5-overview ASP.NET 5概观(ASP.NET 5 Overview) 原作: ...
- Ruby on Rail学习笔记
说明:只针对Windows8.1 Windows下,上rubyinstaller上下载最新的railsinstaller包含Ruby2.1的,然后更新gem 用命令: gem update --sys ...
- Nunit单元测试的使用
先建立一个需要测试的项目 安装nunit 通过nuget安装Install-Package Nunit 类前加[TestFixture] 要测试的方法前加[Test] using System; u ...
- Drawable
今天简单的介绍一下有关以下5中的应用: Statelistdrawable Layerdrawable Shapeddrawable Clipdrawable Animationdrawable 1. ...
- Android---WebView显示Html乱码问题
webView.loadData(result,"text/html","UTF-8"); 反正是用上面的方法无法解决乱码的问题. 使用下面的方法就能完美解决了 ...
- squid基础配置
1 2 3 4 5 6 7 8 9 10 vim /etc/squid/squid.conf http_port 192.168.1.12:3128 (可写多个) cache_mem 64MB ...