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

【题意】

题意

【题解】

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

【代码】

#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. (四)python自带解释器(IDLE)的使用

    什么是IDE? Integrated Development Environment(集成开发环境) 打个不恰当的比方,如果说写代码是制作一件工艺品,那IDE就是机床.再打个不恰当的比方,PS就是图片 ...

  2. 洛谷 P4585 [FJOI2015]火星商店问题

    (勿看,仅作笔记) bzoj权限题... https://www.luogu.org/problemnew/show/P4585 对于特殊商品,直接可持久化trie处理一下即可 剩下的,想了一段时间c ...

  3. 状态压缩DP SRM 667 Div1 OrderOfOperations 250

    Problem Statement      Cat Noku has just finished writing his first computer program. Noku's compute ...

  4. jmeter(二十)JMeter中返回Json数据的处理方法

    Json 作为一种数据交换格式在网络开发,特别是 Ajax 与 Restful 架构中应用的越来越广泛.而 Apache 的 JMeter 也是较受欢迎的压力测试工具之一,但是它本身没有提供对于 Js ...

  5. 正则表达式test报错 is not a function

    var reg = "/^1[34578]\d{9}$/"; //错误格式,这是一个字符串 var reg2 = /^1[34578]\d{9}$/; //正确格式 reg .te ...

  6. C#基础学习5

    数组集合

  7. AJPFX浅谈Java新手问题之缺少良好的编程习惯

    ★随意地命名 有些新手写程序,当需要定义某个变量名(也可能是函数名.类名.包名等)时,随意地一敲键盘,名字就起好了......若干星期后,碰到某 bug,再来看自己写的代码时,心中暗自嘀咕:“这代码是 ...

  8. grunt配置详情

    这个grunt配置 是我的一个程序员朋友从网上无意间看到的,然后他亲测了下,恩,是可以的.不过我到目前还未测试过是否可以. 一.安装node, 首先确保电脑已有node的环境.然后 运行  npm i ...

  9. 使用ABAP正则表达式解析HTML标签

    需求就是我用ABAP的某个函数从数据库读取一个字符串出来,该字符串的内容是一个网页. 网页的form里包含了很多隐藏的input field.我的任务是解析出name为svyValueGuid的inp ...

  10. AWS Data Lake Service Stack