【Codeforces Round #424 (Div. 2) A】Unimodal Array
【Link】:http://codeforces.com/contest/831/problem/A
【Description】 
 
让你判断一个数列是不是这样一个数列: 
一开始是严格上升 
然后开始全都是一个数字 
然后又开始严格下降
【Solution】 
 
枚举中间全部相同的是哪个数字; 
假设是i..j这一段 
则看看1..i是不是严格上升,以及j+1..n是不是严格下降; 
如果所有的这样的i..j都不满足则无解; 
找到一组则有解; 
 
【NumberOf WA】 
 
0 
 
【Reviw】 
 
找到最特殊的地方; 
抓住问题的重点! 
 
【Code】
#include <bits/stdc++.h>
using namespace std;
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define LL long long
#define rep1(i,a,b) for (int i = a;i <= b;i++)
#define rep2(i,a,b) for (int i = a;i >= b;i--)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ms(x,y) memset(x,y,sizeof x)
#define Open() freopen("F:\\rush.txt","r",stdin)
#define Close() ios::sync_with_stdio(0)
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;
typedef set<int> myset;
const int dx[9] = {0,1,-1,0,0,-1,-1,1,1};
const int dy[9] = {0,0,0,-1,1,-1,1,-1,1};
const double pi = acos(-1.0);
const int N = 2e3;
struct abc{
    int x,id;
};
int k,n,a[N+100],b[N+100],pre[N+100],ans,tot;
map <int,int> dic;
abc c[N*N+10];
bool cmp(abc a,abc b){
    return a.x < b.x;
}
int main(){
    //Open();
    //Close();
    scanf("%d%d",&k,&n);
    rep1(i,1,k)
        scanf("%d",&a[i]);
    pre[0] = 0;
    rep1(i,1,k)
        pre[i] = pre[i-1] + a[i];
    rep1(i,1,n)
        scanf("%d",&b[i]);
    rep1(i,1,k){
        rep1(j,1,n){
            int x = b[j]-pre[i];
            tot++;
            c[tot].x = x,c[tot].id = j;
        }
    }
    sort(c+1,c+1+tot,cmp);
    rep1(i,1,tot){
        int num = n;
        int j = i;
        while (j+1<=tot && c[j+1].x==c[i].x) j++;
        rep1(k,i,j){
            if (dic[c[k].id]!=i){
                num--;
                dic[c[k].id] = i;
            }
        }
        if (num==0) ans++;
        i = j;
    }
    printf("%d\n",ans);
    return 0;
}
/*
    写完之后,明确每一步的作用
*/
【Codeforces Round #424 (Div. 2) A】Unimodal Array的更多相关文章
- 【Codeforces Round #424 (Div. 2) B】Keyboard Layouts
		
[Link]:http://codeforces.com/contest/831/problem/B [Description] 两个键盘的字母的位置不一样; 数字键的位置一样; 告诉你第一个键盘按某 ...
 - 【Codeforces Round #424 (Div. 2) C】Jury Marks
		
[Link]:http://codeforces.com/contest/831/problem/C [Description] 有一个人参加一个比赛; 他一开始有一个初始分数x; 有k个评委要依次对 ...
 - 【Codeforces Round #424 (Div. 2) D】Office Keys
		
[Link]:http://codeforces.com/contest/831/problem/D [Description] 有n个人,它们都要去一个终点,终点位于p; 但是,在去终点之前,他们都 ...
 - 【Codeforces Round #432 (Div. 1) B】Arpa and a list of numbers
		
[链接]h在这里写链接 [题意] 定义bad list是一个非空的.最大公约数为1的序列.给定一个序列,有两种操作:花费x将一个元素删除.花费y将一个元素加1,问你将这个序列变为good list所需 ...
 - 【Codeforces Round #420 (Div. 2) C】Okabe and Boxes
		
[题目链接]:http://codeforces.com/contest/821/problem/C [题意] 给你2*n个操作; 包括把1..n中的某一个数压入栈顶,以及把栈顶元素弹出; 保证压入和 ...
 - 【Codeforces Round #420 (Div. 2) B】Okabe and Banana Trees
		
[题目链接]:http://codeforces.com/contest/821/problem/B [题意] 当(x,y)这个坐标中,x和y都为整数的时候; 这个坐标上会有x+y根香蕉; 然后给你一 ...
 - 【Codeforces Round #420 (Div. 2) A】Okabe and Future Gadget Laboratory
		
[题目链接]:http://codeforces.com/contest/821/problem/A [题意] 给你一个n*n的数组; 然后问你,是不是每个位置(x,y); 都能找到一个同一行的元素q ...
 - 【Codeforces Round #423 (Div. 2) C】String Reconstruction
		
[Link]:http://codeforces.com/contest/828/problem/C [Description] 让你猜一个字符串原来是什么; 你知道这个字符串的n个子串; 且知道第i ...
 - 【Codeforces Round #423 (Div. 2) B】Black Square
		
[Link]:http://codeforces.com/contest/828/problem/B [Description] 给你一个n*m的格子; 里面包含B和W两种颜色的格子; 让你在这个格子 ...
 
随机推荐
- luogu 1280 尼克的任务
			
题目描述 尼克每天上班之前都连接上英特网,接收他的上司发来的邮件,这些邮件包含了尼克主管的部门当天要完成的全部任务,每个任务由一个开始时刻与一个持续时间构成. 尼克的一个工作日为N分钟,从第一分钟开始 ...
 - BZOJ 2424 DP OR 费用流
			
思路: 1.DP f[i][j]表示第i个月的月底 还剩j的容量 转移还是相对比较好想的-- f[i][j+1]=min(f[i][j+1],f[i][j]+d[i]); if(j>=u[i+1 ...
 - POJ 3122 Pie 二分答案
			
题意:给你n个派,每个派都是高为一的圆柱体,把它等分成f份,每份的最大体积是多少. 思路: 明显的二分答案题-- 注意π的取值- 3.14159265359 这样才能AC,,, //By Sirius ...
 - Google Codejam 2016 Round1A Problem C BFFs 简单图论
			
链接 Google Codejam 2016 Round1A Problem C BFFs 题意 n个小朋友要坐成一个圈.每个小朋友心中都有一个Best Friend Forever.要保证每个人的左 ...
 - View简介
			
1.View 是所有widget类的基类 2.View的坐标 根据上面的图应该会比较容易明白,图中屏幕上放了一个ViewGroup布局,里面有个View控件 getTop:获取到的,是view自身的顶 ...
 - 使用U盘安装win8(win8.1)系统
			
下载镜像 下载系统镜像,可以选32位或64位.下完后放到非系统盘(如果需要重新分区的,要先保存到移动硬盘或U盘) 使用U盘制作PE 准备一个4G以上的U盘(备份好U盘里的资料,因为刻录PE需要格式化U ...
 - rem自适应布局-移动端自适应必备:flexible.js
			
http://caibaojian.com/flexible-js.html
 - Data flow diagram-数据流图
			
A DFD shows what kind of information will be input to and output from the system, how the data will ...
 - nginx的Rewrite重写
			
location /{ if ($remote_addr=192.168.1.100){ //禁止此 ip 访问 ...
 - 洛谷1440 求m区间的最小值 单调队列
			
题目描述 一个含有n项的数列(n<=2000000),求出每一项前的m个数到它这个区间内的最小值.若前面的数不足m项则从第1个数开始,若前面没有数则输出0. 输入格式: 第一行两个数n,m. 第 ...