码迷,mamicode.com
首页 > 其他好文 > 详细

map,实现技巧,id

时间:2018-09-13 20:53:55      阅读:162      评论:0      收藏:0      [点我收藏+]

标签:memset   cas   bsp   push   std   pair   cstring   alt   als   

cf

技术分享图片
 1 #include<iostream>
 2 #include<cstdio>
 3 #include<algorithm>
 4 #include<vector>
 5 #include<cstring>
 6 #include<map>
 7 #include<set>
 8 #include<cmath>
 9 #include<queue>
10 #include<bitset>
11 #include<utility>
12 #include<functional>
13 #include<iomanip>
14 #include<sstream>
15 #include<ctime>
16 #include<cassert>
17 #define A first
18 #define B second
19 #define mp make_pair
20 #define pb push_back
21 #define pw(x) (1ll << (x))
22 #define sz(x) ((int)(x).size())
23 #define all(x) (x).begin(),(x).end()
24 #define rep(i,l,r) for(int i=(l);i<(r);i++)
25 #define per(i,r,l) for(int i=(r);i>=(l);i--)
26 #define FOR(i,l,r) for(int i=(l);i<=(r);i++)
27 #define eps 1e-9
28 #define PIE acos(-1)
29 #define cl(a,b) memset(a,b,sizeof(a))
30 #define fastio ios::sync_with_stdio(false);cin.tie(0);
31 #define lson l , mid , ls
32 #define rson mid + 1 , r , rs
33 #define ls (rt<<1)
34 #define rs (ls|1)
35 #define INF 0x3f3f3f3f
36 #define lowbit(x) (x&(-x))
37 #define sqr(a) a*a
38 #define ll long long
39 #define ull unsigned long long
40 #define vi vector<int>
41 #define pii pair<int, int>
42 #define dd(x) cout << #x << " = " << (x) << ", "
43 #define de(x) cout << #x << " = " << (x) << "\n"
44 #define endl "\n"
45 using namespace std;
46 //**********************************
47 int n,m;
48 const int maxn=1e5+300;
49 int a[maxn],b[maxn],c[maxn];
50 //**********************************
51 
52 //**********************************
53 int main()
54 {
55     cin>>n;
56     int cnt=1;
57     FOR(i,1,n){
58         scanf("%d",&a[i]);
59         if(a[i]>a[i-1]&&i!=1)cnt++;
60         else cnt=1;
61         c[i]=cnt;
62         b[i]=i-cnt+1;
63     }
64     int ans=1;
65     FOR(i,1,n){
66 //        ans=max(ans,b[i])
67         dd(i);dd(b[i]);de(c[i]);
68         if(a[i+1]>=a[i-1]+2&&(a[i]<=a[i-1]||a[i]>=a[i+1]))ans=max(ans,b[i]+c[i]);
69     }
70     cout<<ans<<endl;
71     return 0;
72 }
View Code

 

map,实现技巧,id

标签:memset   cas   bsp   push   std   pair   cstring   alt   als   

原文地址:https://www.cnblogs.com/klaycf/p/9642960.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!