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

【题意】

题意

【题解】

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

【代码】

#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. UIBarButtonItem系统默认风格形状

    typedef NS_ENUM(NSInteger, UIBarButtonSystemItem) { UIBarButtonSystemItemDone, UIBarButtonSystemItem ...

  2. SpringCloud开发学习总结(七)—— 声明式服务调用Feign(二)

    参数绑定 在上一章的示例中,我们使用Spring Cloud Feign实现的是一个不带参数的REST服务绑定.然而现实系统中的各种业务接口要比它复杂得多,我们有时会在HTTP的各个位置传入各种不同类 ...

  3. python tkinter窗口弹出置顶的方法

    加上下面两句即可实现root窗口的置顶显示,可以用于某些程序的消息提示,能够弹出到桌面显示 root = Tk() root.wm_attributes('-topmost',1)

  4. scau 1144 数星星 bit + 扫描线的思想

    这题如果用二维树状数组,则会直接爆内存. 那么可以运用扫描线的思路. 就是,它同时被x和y限制了,那么可以在查询的时候,确保x先满足了,(把x按小到大排序) 然后就相当于是关于y的一个一维bit了, ...

  5. PV,UV,IP概念

    PV是网站分析的一个术语,用以衡量网站用户访问的网页的数量.对于广告主,PV值可预期它可以带来多少广告收入.一般来说,PV与来访者的数量成正比,但是PV并不直接决定页面的真实来访者数量,如同一个来访者 ...

  6. .net core跨域设置

    services.AddCors(options => options.AddPolicy("AllowSameDomain", builder => builder. ...

  7. poj2282The Counting Problem(组合)

    链接 计算0-9每一个数字出现的次数 逐位进行处理 对于每一位取几时依次算下组合的情况 注意0的情况需要特殊处理一下 因为0000 00 这样都是等于0的 前面的几位是多余的 #include < ...

  8. poj3280 Cheapest Palindrome

    思路: 区间dp.添加和删除本质相同. 实现: #include <iostream> #include <cstdio> using namespace std; int n ...

  9. vue下axios和fetch跨域请求

    1.在config的index.js下面进行常用跨域配置代码:proxyTable: { '/apis': { //使用"/api"来代替"http://xxxx.cn& ...

  10. 【转】密码学 :CSP的概念

    转:[密码学]CSP的概念 CSP加密服务提供者(Cryptographic Service Provider)具有一下几个特点: CSP是真正执行密码运算的独立模块 物理上一个CSP由两部分组成:一 ...