-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy path1130A. Be Positive.cpp
90 lines (73 loc) · 2.44 KB
/
1130A. Be Positive.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
/***
Bismillahir Rahmanir Rahim
Read in the name of Allah, who created you!!!
Author : Shah Newaj Rabbi Shishir,
Department of CSE, City University, Bangladesh.
***/
#include <bits/stdc++.h>
using namespace std;
#define ebar_khela_jombe_besh int main (void)
#define jitsen_bhai return 0
#define sf scanf
#define pf printf
#define ssf sscanf
#define spf sprintf
#define fsf fscanf
#define fpf fprintf
#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define scase sf ("%d",&tc)
#define sn sf ("%d",&n)
#define whilecase while (tc--)
#define eof while (cin >> n)
#define forloop for (pos=1; pos<=tc; pos++)
#define arrayloop for (i=0; i<n; i++)
#define cinstr cin >> str
#define getstr getline (cin,str)
#define pcase pf ("Case %d: ",pos)
#define vi vector <int>
#define si set <int>
#define vs vector <string>
#define pii pair <int,int>
#define mii map <int,int>
#define pb push_back
#define in insert
#define llu unsigned long long
#define lld long long
#define U unsigned int
#define endl "\n"
int SetBit (int n, int x) { return n | (1 << x); }
int ClearBit (int n, int x) { return n & ~(1 << x); }
int ToggleBit (int n, int x) { return n ^ (1 << x); }
bool CheckBit (int n, int x) { return (bool)(n & (1 << x)); }
int arr[200005];
ebar_khela_jombe_besh
{
/*
freopen ("input.txt","r",stdin);
freopen ("output.txt","w",stdout);
*/
int n,i,val,ans;
while (sf ("%d",&n) != EOF)
{
vi v(n+2),p;
ans = 0;
for (i=1; i<=n; i++)
{
sf ("%d",&arr[i]);
if (arr[i])
v[i] = v[i-1]+1;
else
{
v[i] = 0;
if (p.size() == 0)
p.pb(i-1);
}
ans = max (ans,v[i]);
}
if (arr[n] == 1)
ans = max (ans,v[n]+p[0]);
pf ("%d\n",ans);
v.clear();
}
jitsen_bhai;
}