#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e4;
int n, a[maxn], cnt = 1, maxtwist = 0;
map<int,int> mp;
void pre(){
for(int i = 1; i <= n; i++){
mp[a[i]]++;
if(mp[2] == mp[1]) cnt++;
}
}
void result(){
cout << mp[1] << " " << mp[2] << '\n';
}
void draw(){
cout << cnt << '\n';
}
void twist(){
int st = a[1];
int num = 0;
for(int i = 1; i <= n; i++){
if(a[i] == st) num++;
else{
st = a[i];
maxtwist = max(maxtwist, num);
num = 1;
}
}
maxtwist = max(maxtwist, num);
cout << maxtwist;
}
int main(){
cin >> n;
for(int i = 1; i <= n; i++){
cin >> a[i];
}
pre();
result();
draw();
twist();
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
304 KB |
Output is correct |
4 |
Correct |
0 ms |
308 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Partially correct |
0 ms |
212 KB |
Output is partially correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Partially correct |
1 ms |
212 KB |
Output is partially correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |