【Codeforces 1108E1】Array and Segments (Easy version)
【链接】 我是链接,点我呀:)
【题意】
题意
【题解】
枚举最大值和最小值在什么地方。
显然,只要包含最小值的区间,都让他减少。
因为就算那个区间包含最大值,也无所谓,因为不会让答案变小。
但是那些不包含最大值的区间却能让差值变大。
所以没有问题。
【代码】
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 300;
int n,m;
int a[N+10],segl[N+10],segr[N+10];
int cnt[N+10],idxi;
int main(){
ios::sync_with_stdio(0),cin.tie(0);
cin >> n >> m;
for (int i = 1;i <= n;i++){
cin >> a[i];
}
for (int i = 1;i <= m;i++){
cin >> segl[i] >> segr[i];
}
int ans = 0,anscnt=0;
for (int i = 1;i <= n;i++)//a[i]最大
for (int j = 1;j <= n;j++){//a[j]最小
int x = a[i],y = a[j];
int cnt = 0;
for (int l = 1;l <= m;l++){
if (segl[l]<=j && j <= segr[l]){
cnt++;
y--;
if (segl[l]<=i && i <= segr[l]){
x--;
}
}
}
if (x-y>ans){
ans = x-y;
idxi = j;
anscnt = cnt;
}
}
cout<<ans<<endl;
cout<<anscnt<<endl;
for (int l = 1;l <= m;l++){
if (segl[l]<=idxi && idxi<=segr[l]){
cout<<l<<" ";
}
}
return 0;
}
【Codeforces 1108E1】Array and Segments (Easy version)的更多相关文章
- 【Codeforces 1118D1】Coffee and Coursework (Easy version)
[链接] 我是链接,点我呀:) [题意] 题意 [题解] 从小到大枚举天数. 然后贪心地,从大到小分配a[i]到各个天当中. a[n]分配到第1天,a[n-1]分配到第2天,...然后a[n-x]又分 ...
- 【20.51%】【codeforces 610D】Vika and Segments
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...
- 【codeforces 797E】Array Queries
[题目链接]:http://codeforces.com/problemset/problem/797/E [题意] 给你一个n个元素的数组; 每个元素都在1..n之间; 然后给你q个询问; 每个询问 ...
- Array and Segments (Easy version) CodeForces - 1108E1 (暴力枚举)
The only difference between easy and hard versions is a number of elements in the array. You are giv ...
- 【CodeForces 624D】Array GCD
题 You are given array ai of length n. You may consecutively apply two operations to this array: remo ...
- 【Codeforces 1185C2】Exam in BerSU (hard version)
[链接] 我是链接,点我呀:) [题意] 要让前i个数字的和小于等于M. 问你最少要删掉前i-1个数字中的多少个数字,每个询问都是独立的. [题解] ti的范围很小. 所以N*MAX(TI)暴力枚举就 ...
- E1. Array and Segments (Easy version)(暴力) && E2. Array and Segments (Hard version)(线段树维护)
题目链接: E1:http://codeforces.com/contest/1108/problem/E1 E2:http://codeforces.com/contest/1108/problem ...
- Codeforces 1108E2 Array and Segments (Hard version) 差分, 暴力
Codeforces 1108E2 E2. Array and Segments (Hard version) Description: The only difference between eas ...
- Codeforces Round #535 (Div. 3) E2. Array and Segments (Hard version) 【区间更新 线段树】
传送门:http://codeforces.com/contest/1108/problem/E2 E2. Array and Segments (Hard version) time limit p ...
随机推荐
- 【poj2528】Mayor's posters
Mayor's posters Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 64939 Accepted: 18770 ...
- 1051 - Good or Bad DFS 记忆化搜索
http://lightoj.com/volume_showproblem.php?problem=1051 对于每个位置,设dfs(cur, one, two)表示前i个字母,拥有辅音字母one个, ...
- MySQL与RAID
RAID在mysq中适用场景 raid0:由于性能高和成本低,以及基本没有数据恢复的能力,而且它比单片磁盘损坏的概率要高.建议只在不担心数据丢失的情况下使用,如备库(slave)或者某些原因" ...
- Camera和 tris,verts的优化
Unity的Camera组件有很多可调节的参数,当需要做优化的时候,stats面板中的tris和verts这两个重点项都与Camera组件的参数有很大关系,有些参数的意义Unity手册说得不够详细,经 ...
- Masonry自动布局与UIScrolView适配
Masonry介绍 Masonry是一个轻量级的布局框架 拥有自己的描述语法 采用更优雅的链式语法封装自动布局 简洁明了 并具有高可读性 而且同时支持 iOS 和 Max OS X.可以通过cocoa ...
- IF-MIB::ifTable = No Such Object available on this agent at this OID
在server端口执行如下命令 [root@localhost ~]# snmpwalk -v2c -c public 客户端ip ifIF-MIB::ifTable = No Such Object ...
- AI学习一:环境安装
对于Python开发用户来讲,PIP安装软件包是家常便饭.但国外的源下载速度实在太慢,浪费时间.而且经常出现下载后安装出错问题.所以把PIP安装源替换成国内镜像,可以大幅提升下载速度,还可以提高安装成 ...
- 从零开始部署小型企业级虚拟桌面 -- Vmware Horizon View 6 For Linux VDI
环境说明 注,本套环境所用机器全部是64位的. 管理服务器载体:安装win7操作系统,通过VMware Workstation安装4台虚拟机,用作vCenter,Connection Server,D ...
- HDU 5414 CRB and String (字符串,模拟)
题意:给两个字符串s和t,如果能插入一些字符使得s=t,则输出yes,否则输出no.插入规则:在s中选定一个字符c,可以在其后面插入一个字符k,只要k!=c即可. 思路:特殊的情况就是s和t的最长相同 ...
- 伪类的格式重点:父标签层级 & 当前标签类型
伪类的格式重点:父标签层级 & 当前标签类型 通过例子说明: css1: span:nth-of-type(2){color: red;} css2: span :nth-of-type(2) ...