【Link】:http://codeforces.com/contest/831/problem/A

【Description】



让你判断一个数列是不是这样一个数列:

一开始是严格上升

然后开始全都是一个数字

然后又开始严格下降

【Solution】



枚举中间全部相同的是哪个数字;

假设是i..j这一段

则看看1..i是不是严格上升,以及j+1..n是不是严格下降;

如果所有的这样的i..j都不满足则无解;

找到一组则有解;



【NumberOf WA】



0



【Reviw】



找到最特殊的地方;

抓住问题的重点!



【Code】

  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define lson l,m,rt<<1
  4. #define rson m+1,r,rt<<1|1
  5. #define LL long long
  6. #define rep1(i,a,b) for (int i = a;i <= b;i++)
  7. #define rep2(i,a,b) for (int i = a;i >= b;i--)
  8. #define mp make_pair
  9. #define pb push_back
  10. #define fi first
  11. #define se second
  12. #define ms(x,y) memset(x,y,sizeof x)
  13. #define Open() freopen("F:\\rush.txt","r",stdin)
  14. #define Close() ios::sync_with_stdio(0)
  15. typedef pair<int,int> pii;
  16. typedef pair<LL,LL> pll;
  17. typedef set<int> myset;
  18. const int dx[9] = {0,1,-1,0,0,-1,-1,1,1};
  19. const int dy[9] = {0,0,0,-1,1,-1,1,-1,1};
  20. const double pi = acos(-1.0);
  21. const int N = 2e3;
  22. struct abc{
  23. int x,id;
  24. };
  25. int k,n,a[N+100],b[N+100],pre[N+100],ans,tot;
  26. map <int,int> dic;
  27. abc c[N*N+10];
  28. bool cmp(abc a,abc b){
  29. return a.x < b.x;
  30. }
  31. int main(){
  32. //Open();
  33. //Close();
  34. scanf("%d%d",&k,&n);
  35. rep1(i,1,k)
  36. scanf("%d",&a[i]);
  37. pre[0] = 0;
  38. rep1(i,1,k)
  39. pre[i] = pre[i-1] + a[i];
  40. rep1(i,1,n)
  41. scanf("%d",&b[i]);
  42. rep1(i,1,k){
  43. rep1(j,1,n){
  44. int x = b[j]-pre[i];
  45. tot++;
  46. c[tot].x = x,c[tot].id = j;
  47. }
  48. }
  49. sort(c+1,c+1+tot,cmp);
  50. rep1(i,1,tot){
  51. int num = n;
  52. int j = i;
  53. while (j+1<=tot && c[j+1].x==c[i].x) j++;
  54. rep1(k,i,j){
  55. if (dic[c[k].id]!=i){
  56. num--;
  57. dic[c[k].id] = i;
  58. }
  59. }
  60. if (num==0) ans++;
  61. i = j;
  62. }
  63. printf("%d\n",ans);
  64. return 0;
  65. }
  66. /*
  67. 写完之后,明确每一步的作用
  68. */

【Codeforces Round #424 (Div. 2) A】Unimodal Array的更多相关文章

  1. 【Codeforces Round #424 (Div. 2) B】Keyboard Layouts

    [Link]:http://codeforces.com/contest/831/problem/B [Description] 两个键盘的字母的位置不一样; 数字键的位置一样; 告诉你第一个键盘按某 ...

  2. 【Codeforces Round #424 (Div. 2) C】Jury Marks

    [Link]:http://codeforces.com/contest/831/problem/C [Description] 有一个人参加一个比赛; 他一开始有一个初始分数x; 有k个评委要依次对 ...

  3. 【Codeforces Round #424 (Div. 2) D】Office Keys

    [Link]:http://codeforces.com/contest/831/problem/D [Description] 有n个人,它们都要去一个终点,终点位于p; 但是,在去终点之前,他们都 ...

  4. 【Codeforces Round #432 (Div. 1) B】Arpa and a list of numbers

    [链接]h在这里写链接 [题意] 定义bad list是一个非空的.最大公约数为1的序列.给定一个序列,有两种操作:花费x将一个元素删除.花费y将一个元素加1,问你将这个序列变为good list所需 ...

  5. 【Codeforces Round #420 (Div. 2) C】Okabe and Boxes

    [题目链接]:http://codeforces.com/contest/821/problem/C [题意] 给你2*n个操作; 包括把1..n中的某一个数压入栈顶,以及把栈顶元素弹出; 保证压入和 ...

  6. 【Codeforces Round #420 (Div. 2) B】Okabe and Banana Trees

    [题目链接]:http://codeforces.com/contest/821/problem/B [题意] 当(x,y)这个坐标中,x和y都为整数的时候; 这个坐标上会有x+y根香蕉; 然后给你一 ...

  7. 【Codeforces Round #420 (Div. 2) A】Okabe and Future Gadget Laboratory

    [题目链接]:http://codeforces.com/contest/821/problem/A [题意] 给你一个n*n的数组; 然后问你,是不是每个位置(x,y); 都能找到一个同一行的元素q ...

  8. 【Codeforces Round #423 (Div. 2) C】String Reconstruction

    [Link]:http://codeforces.com/contest/828/problem/C [Description] 让你猜一个字符串原来是什么; 你知道这个字符串的n个子串; 且知道第i ...

  9. 【Codeforces Round #423 (Div. 2) B】Black Square

    [Link]:http://codeforces.com/contest/828/problem/B [Description] 给你一个n*m的格子; 里面包含B和W两种颜色的格子; 让你在这个格子 ...

随机推荐

  1. PHP第九课 正則表達式在PHP中的使用

    今天内容 1.正則表達式 2.数学函数 3.日期函数 4.错误处理 正則表達式: 1.模式修正符 2.五个经常使用函数 另外一个正則表達式的站点:http://www.jb51.net/tools/z ...

  2. NPOI操作Excel 004:写入空Excel(添加保存提示框)

    前文说道写入excel的样例,当中保存Excle后须要添加提示框.让用户自己选择保存路径,做改动例如以下. 引用的dll等前面已经说过了, 直接看代码: protected void Btn_Writ ...

  3. Data Member Order

    https://docs.microsoft.com/en-us/dotnet/framework/wcf/feature-details/data-member-order In some appl ...

  4. Import Example Dataset

    Overview The examples in this guide use the restaurants collection in the test database. The followi ...

  5. Lambda表达式-使用说明

    jdk8已经发布4年,其中有一个特性:Lambda,它是一个令开发者便捷开发的一种方式,Lambda Expression (Lambda表达式)是为了让java提供一种面向函数编程,原本在jdk8之 ...

  6. spring的quartz定时任务

    一.版本: 1.spring:4.1.7:    2.quartz:2.2.1: 二.基于ssm项目: 1.引入jar包:quartz-2.2.1.jar:spring所需包. 2.说明:quartz ...

  7. 【DNN 系列】 模块开发 8.0.1

    1.创建第一个模块需要准备的东西有 https://github.com/dnnsoftware/DNN.Templates/releases/tag/1.0.1 VS 2015 插件 创建一个项目M ...

  8. PostgreSQL Replication之第四章 设置异步复制(4)

    4.4 基于流和基于文件的恢复 生活并不总只是黑色或白色:有时也会有一些灰色色调.对于某些情况下,流复制可能恰到好处.在另一些情况下,基于文件复制和PITR是您所需要的.但是也有许多情况下,您既需要流 ...

  9. c# 对用户密码加密解密

    一.使用16位.32位.64位MD5方法对用户名加密 1)16位的MD5加密 ? 1 2 3 4 5 6 7 8 9 10 11 12 /// <summary> /// 16位MD5加密 ...

  10. Hope is a good thing, maybe the best of things and no good thing ever dies !