답안 #498981

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
498981 2021-12-26T21:36:11 Z inksamurai Preokret (COCI19_preokret) C++17
16 / 50
1 ms 204 KB
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define sz(a) (int)a.size()
#define all(a) a.begin(),a.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define crep(i,x,n) for(int i=x;i<n;i++)
#define drep(i,n) for(int i=n-1;i>=0;i--)
#define vec(...) vector<__VA_ARGS__>
#define _3qplfh5 ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
using namespace std;
typedef long long ll;
typedef long double ld;
using pii=pair<int,int>;
using vi=vector<int>;
using vll=vector<long long>;

int main(){
_3qplfh5;
	int n;
	cin>>n;
	vi a(n);
	rep(i,n){
		cin>>a[i];
	}
	int _a=0,_b=0,tie=1,ma=0;
	for(int i=0;i<n;){
		int cnt=1,t=0;
		int oa=_a,ob=_b;
		if(a[i]==1){
			_a++;
			if(_a<_b) t=1;
		}else{
			_b++;
			if(_a>_b) t=2;
		}
		while(i+1<n and a[i]==a[i+1]){
			if(a[i]==1) _a++;
			else _b++;
			if(_a==_b) tie++;
			cnt++;
			i=i+1;
		}
		if(_a>_b){
			if(t==1){
				ma=max(ma,_b+1-oa);
			}
		}
		if(_b>_a){
			if(t==2){
				ma=max(ma,_a+1-ob);
			}
		}
		i=i+1;
	}
	cout<<_a<<" "<<_b<<"\n";
	cout<<tie<<"\n";
	cout<<ma<<"\n";
//	
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Partially correct 0 ms 204 KB Output is partially correct
2 Partially correct 0 ms 204 KB Output is partially correct
3 Partially correct 0 ms 204 KB Output is partially correct
4 Partially correct 0 ms 204 KB Output is partially correct
5 Partially correct 1 ms 204 KB Output is partially correct
6 Partially correct 0 ms 204 KB Output is partially correct
7 Partially correct 0 ms 204 KB Output is partially correct
8 Partially correct 0 ms 204 KB Output is partially correct
9 Partially correct 0 ms 204 KB Output is partially correct
10 Partially correct 0 ms 204 KB Output is partially correct