# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
209334 | papa | Preokret (COCI19_preokret) | C++14 | 5 ms | 508 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
int n;
int s1[300];
int s2[300];
//ideja je samo simulacija
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cerr.tie(0);
cin >> n;
s1[0] = 0;
s2[0] = 0;
int cnt = 1;
int c1 = 0;
int c2 = 0;
int ma = -1;
for(int i=1;i<=n;i++)
{
int x;
cin >> x;
if(x==1)
{
s1[i] = s1[i-1]+1;
s2[i] = s2[i-1];
if(c1==0)
{
if(c2!=0)
{
//cout << "uso 1" << "\n";
int pre = i-1-c2;
int kraj = i-1;
if(s1[pre] > s2[pre] && s2[kraj] > s1[kraj]) ma = max(ma,c2);
}
c2=0;
}
c1++;
}
else
{
s1[i] = s1[i-1];
s2[i] = s2[i-1] +1;
if(c2==0)
{
if(c1!=0)
{
//cout << "uso 2" << "\n";
int pre = i-1-c1;
int kraj = i-1;
if(s1[pre] < s2[pre] && s2[kraj] < s1[kraj]) ma = max(ma,c1);
}
c1=0;
}
c2++;
}
if(s1[i] == s2[i]) cnt++;
}
if(c1!=0)
{
//cout << "uso 1 kr" << "\n";
int pre = n-c1;
int kraj = n;
if(s1[pre] < s2[pre] && s2[kraj] < s1[kraj]) ma = max(ma,c1);
}
if(c2!=0)
{
//cout << "uso 2 kr" << "\n";
int pre = n-c2;
int kraj = n;
//cout << s1[pre] << " " << s2[pre] << " " << s1[kraj] << " " << s2[kraj] << "\n";
if(s1[pre] > s2[pre] && s2[kraj] > s1[kraj]) ma = max(ma,c2);
}
cout << s1[n] << " " << s2[n] << "\n" << cnt << "\n" << ma;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |