Submission #30237803
Source Code Expand
Copy
#include <bits/stdc++.h>#include <assert.h>#define SZ(container) container.size()#define REP(i, n) for (auto i = 0; i < n; ++i)#define REV(i, n) for (auto i = n - 1; i >= 0; --i)#define RANGE(i, a, b) for (auto i = a; i <= b; ++i)#define FOR(e, container) for (auto e : container)#define ITE(e, container) for (auto e = container.begin(); e != container.end(); ++e)#define ALL(container) container.begin(), container.end()#define MP(a, b) make_pair(a, b)using namespace std;typedef long long ll;typedef vector<int> vi;void SetIO(){ios::sync_with_stdio(0);cin.tie(0);
#include <bits/stdc++.h> #include <assert.h> #define SZ(container) container.size() #define REP(i, n) for (auto i = 0; i < n; ++i) #define REV(i, n) for (auto i = n - 1; i >= 0; --i) #define RANGE(i, a, b) for (auto i = a; i <= b; ++i) #define FOR(e, container) for (auto e : container) #define ITE(e, container) for (auto e = container.begin(); e != container.end(); ++e) #define ALL(container) container.begin(), container.end() #define MP(a, b) make_pair(a, b) using namespace std; typedef long long ll; typedef vector<int> vi; void SetIO() { ios::sync_with_stdio(0); cin.tie(0); } int main(int argc, char const *argv[]) { SetIO(); int n; cin >> n; vi a(n); REP(i, n) cin >> a[i]; int ans=1; int c=0; int best=0; REP(i, n) { if (a[i]) { c++; } else { if (c > best) { best=c; } c=0; } } if (c>0&&c>best) best=c; ans+=best; c=0; best=0; REP(i, n) { if (!a[i]) { c++; } else { if (c > best) { best=c; } c=0; } } if (c>0&&c>best) best=c; ans += best; cout << ans << "\n"; return 0; }
Submission Info
Submission Time | |
---|---|
Task | B - Count 1's |
User | janux |
Language | C++ (GCC 9.2.1) |
Score | 0 |
Code Size | 1176 Byte |
Status | WA |
Exec Time | 29 ms |
Memory | 4508 KB |
Compile Error
./Main.cpp: In function ‘int main(int, const char**)’: ./Main.cpp:24:14: warning: unused parameter ‘argc’ [-Wunused-parameter] 24 | int main(int argc, char const *argv[]) | ~~~~^~~~ ./Main.cpp:24:32: warning: unused parameter ‘argv’ [-Wunused-parameter] 24 | int main(int argc, char const *argv[]) | ~~~~~~~~~~~~^~~~~~
Judge Result
Set Name | Sample | All | ||||||
---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 400 | ||||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | 00-sample-001.txt, 00-sample-002.txt, 00-sample-003.txt |
All | 00-sample-001.txt, 00-sample-002.txt, 00-sample-003.txt, 01-001.txt, 01-002.txt, 01-003.txt, 01-004.txt, 01-005.txt, 01-006.txt, 01-007.txt, 01-008.txt, 01-009.txt, 01-010.txt, 01-011.txt, 01-012.txt, 01-013.txt, 01-014.txt, 01-015.txt, 01-016.txt, 01-017.txt, 01-018.txt, 01-019.txt, 01-020.txt, 01-021.txt, 01-022.txt, 01-023.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
00-sample-001.txt | AC | 6 ms | 3476 KB |
00-sample-002.txt | AC | 2 ms | 3592 KB |
00-sample-003.txt | AC | 2 ms | 3560 KB |
01-001.txt | AC | 2 ms | 3432 KB |
01-002.txt | AC | 23 ms | 4248 KB |
01-003.txt | WA | 18 ms | 3960 KB |
01-004.txt | WA | 12 ms | 3596 KB |
01-005.txt | WA | 3 ms | 3508 KB |
01-006.txt | WA | 14 ms | 3660 KB |
01-007.txt | WA | 7 ms | 3492 KB |
01-008.txt | AC | 4 ms | 3548 KB |
01-009.txt | AC | 13 ms | 3484 KB |
01-010.txt | WA | 3 ms | 3612 KB |
01-011.txt | AC | 5 ms | 3696 KB |
01-012.txt | AC | 6 ms | 3612 KB |
01-013.txt | AC | 29 ms | 4344 KB |
01-014.txt | WA | 25 ms | 4352 KB |
01-015.txt | WA | 22 ms | 4336 KB |
01-016.txt | WA | 29 ms | 4452 KB |
01-017.txt | WA | 28 ms | 4332 KB |
01-018.txt | WA | 20 ms | 4388 KB |
01-019.txt | AC | 21 ms | 4460 KB |
01-020.txt | AC | 24 ms | 4488 KB |
01-021.txt | WA | 20 ms | 4508 KB |
01-022.txt | AC | 22 ms | 4456 KB |
01-023.txt | AC | 27 ms | 4476 KB |