# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
420518 | JvThunder | Cigle (COI21_cigle) | C++14 | 1067 ms | 332 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>
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
typedef long long ll;
using namespace std;
int n;
vector<int> v;
void solve()
{
cin >> n;
for(int i=0;i<n;i++)
{
int tmp;
cin >> tmp;
v.pb(tmp);
}
int mxcnt = 0;
for(int mask=0;mask<(1<<n);mask++)
{
int cnt = 0;
set<int> prv;
set<int> curr;
int pos = 0;
int layer = 0;
bool impos = false;
for(int j=1;j<n;j++)
{
int x1 = 0,x2 = 0;
if((1<<j)&mask) x1 = 1;
if((1<<(j-1))&mask) x2 = 1;
if(x1==1 && x2==1) impos = true;
}
if(impos) continue;
for(int j=0;j<n;j++)
{
if((1<<j)&mask)
{
layer++;
prv.clear();
prv = curr;
curr.clear();
}
int sign = 1;
if(layer%2) sign *= -1;
pos += sign*v[j];
if(prv.find(pos)!=prv.end() && ((1<<j+1)&mask)==0 && j!=n-1) cnt++;
curr.insert(pos);
}
mxcnt = max(mxcnt,cnt);
}
cout << mxcnt << endl;
return;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
int tc=1;
//cin>>tc;
for(int i=1;i<=tc;i++) solve();
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |