【链接】 我是链接,点我呀:)

【题意】

题意

【题解】

枚举最大值和最小值在什么地方。
显然,只要包含最小值的区间,都让他减少。
因为就算那个区间包含最大值,也无所谓,因为不会让答案变小。
但是那些不包含最大值的区间却能让差值变大。
所以没有问题。

【代码】

#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)的更多相关文章

  1. 【Codeforces 1118D1】Coffee and Coursework (Easy version)

    [链接] 我是链接,点我呀:) [题意] 题意 [题解] 从小到大枚举天数. 然后贪心地,从大到小分配a[i]到各个天当中. a[n]分配到第1天,a[n-1]分配到第2天,...然后a[n-x]又分 ...

  2. 【20.51%】【codeforces 610D】Vika and Segments

    time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  3. 【codeforces 797E】Array Queries

    [题目链接]:http://codeforces.com/problemset/problem/797/E [题意] 给你一个n个元素的数组; 每个元素都在1..n之间; 然后给你q个询问; 每个询问 ...

  4. 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 ...

  5. 【CodeForces 624D】Array GCD

    题 You are given array ai of length n. You may consecutively apply two operations to this array: remo ...

  6. 【Codeforces 1185C2】Exam in BerSU (hard version)

    [链接] 我是链接,点我呀:) [题意] 要让前i个数字的和小于等于M. 问你最少要删掉前i-1个数字中的多少个数字,每个询问都是独立的. [题解] ti的范围很小. 所以N*MAX(TI)暴力枚举就 ...

  7. 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 ...

  8. Codeforces 1108E2 Array and Segments (Hard version) 差分, 暴力

    Codeforces 1108E2 E2. Array and Segments (Hard version) Description: The only difference between eas ...

  9. 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 ...

随机推荐

  1. 树状数组 POJ 2481 Cows

    题目传送门 #include <cstdio> #include <cstring> #include <algorithm> using namespace st ...

  2. 18.3.2从Class上获取信息(属性)

    package d18_3_1; import java.lang.reflect.Field; import java.util.Arrays; /** * 获取Class对应类所包含的属性的四个方 ...

  3. SecureCRT的配色方法

    配色后效果如下: 下面开始配色 1.首先配置成默认模式 2.终端(Terminal)==>仿真(Emulation) 按图中标注进行勾选,勾选完毕点击确认 2.选项(Options)==> ...

  4. 166 Fraction to Recurring Decimal 分数到小数

    给定两个整数,分别表示分数的分子和分母,返回字符串格式的小数.如果小数部分为循环小数,则将重复部分括在括号内.例如,    给出 分子 = 1, 分母 = 2,返回 "0.5".  ...

  5. Linux在线安装pip和numpy

    最近写Python需要用到numpy包 运行pip install numpy就会自动安装 一.因此需要先安装pip 1.如果安装的是Python>=2.7.9或者Python>=3.4, ...

  6. 构建微服务开发环境6————利用npm安装前端框架

    [内容指引] 安装JQuery组件: 安装BootStrap前端框架; 安装AngularJs前端框架: 安装angular动画模块: 安装angular的ui-router模块. 一.进入下载的目标 ...

  7. ES6学习笔记(3)----字符串的扩展

    参考书<ECMAScript 6入门>http://es6.ruanyifeng.com/ 字符串的扩展ES6之前只能识别\u0000 - \uFFFF 之间的字符,超过此范围,识别会出错 ...

  8. 数据库SQL server 删除一张表中的重复记录

    --建立一张表 create table cat( catId int, catName varchar(40) ) --将下边的插入语句,多执行几次. insert into catvalues(1 ...

  9. Android Studio3.0 Error:Execution failed for task ':app:javaPreCompileDebug' 错误

    Error:Execution failed for task ':app:javaPreCompileDebug'. > Annotation processors must be expli ...

  10. CPLD

    复杂可编程逻辑器件(Complex Programmable Logic Device, CPLD),CPLD适合用来实现各种运算和组合逻辑(combinational logic).一颗CPLD内等 ...