#include<bits/stdc++.h>
using namespace std;
#define N 110
#define INFLL 2000000000000000020
#define pb push_back
typedef long long ll;
typedef pair<ll,ll> pll;
vector<ll>vec;
vector<ll>nvec;
map<ll,ll>freq;
ll vet[N];
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
ll n,i=0,ans=0,resp,dir=1,last=0,j;
cin >> n;
while(i<n)
{
cin >> vet[i];
i++;
}
for(i=0;i<(1<<n);i++)
{
resp=0;
last=0;
vec.clear();
nvec.clear();
for(j=0;j<=n;j++)
{
if(i&(1LL<<j) || j==n)
{
if(!nvec.empty())
nvec.pop_back();
freq.clear();
for(auto x : vec)
{
freq[x]++;
}
for(auto x : nvec)
{
freq[x]++;
resp+=(bool)(freq[x]==2);
}
vec.clear();
for(auto x : nvec)
vec.pb(x);
nvec.clear();
dir*=-1;
}
last+=vet[j]*dir;
nvec.pb(last);
}
ans=max(ans,resp);
}
cout << ans << endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
542 ms |
348 KB |
Output is correct |
2 |
Correct |
537 ms |
344 KB |
Output is correct |
3 |
Correct |
590 ms |
348 KB |
Output is correct |
4 |
Correct |
599 ms |
436 KB |
Output is correct |
5 |
Correct |
554 ms |
348 KB |
Output is correct |
6 |
Correct |
594 ms |
436 KB |
Output is correct |
7 |
Correct |
641 ms |
348 KB |
Output is correct |
8 |
Correct |
621 ms |
444 KB |
Output is correct |
9 |
Correct |
613 ms |
436 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
542 ms |
348 KB |
Output is correct |
2 |
Correct |
537 ms |
344 KB |
Output is correct |
3 |
Correct |
590 ms |
348 KB |
Output is correct |
4 |
Correct |
599 ms |
436 KB |
Output is correct |
5 |
Correct |
554 ms |
348 KB |
Output is correct |
6 |
Correct |
594 ms |
436 KB |
Output is correct |
7 |
Correct |
641 ms |
348 KB |
Output is correct |
8 |
Correct |
621 ms |
444 KB |
Output is correct |
9 |
Correct |
613 ms |
436 KB |
Output is correct |
10 |
Incorrect |
283 ms |
348 KB |
Output isn't correct |
11 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
344 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
542 ms |
348 KB |
Output is correct |
2 |
Correct |
537 ms |
344 KB |
Output is correct |
3 |
Correct |
590 ms |
348 KB |
Output is correct |
4 |
Correct |
599 ms |
436 KB |
Output is correct |
5 |
Correct |
554 ms |
348 KB |
Output is correct |
6 |
Correct |
594 ms |
436 KB |
Output is correct |
7 |
Correct |
641 ms |
348 KB |
Output is correct |
8 |
Correct |
621 ms |
444 KB |
Output is correct |
9 |
Correct |
613 ms |
436 KB |
Output is correct |
10 |
Incorrect |
283 ms |
348 KB |
Output isn't correct |
11 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
542 ms |
348 KB |
Output is correct |
2 |
Correct |
537 ms |
344 KB |
Output is correct |
3 |
Correct |
590 ms |
348 KB |
Output is correct |
4 |
Correct |
599 ms |
436 KB |
Output is correct |
5 |
Correct |
554 ms |
348 KB |
Output is correct |
6 |
Correct |
594 ms |
436 KB |
Output is correct |
7 |
Correct |
641 ms |
348 KB |
Output is correct |
8 |
Correct |
621 ms |
444 KB |
Output is correct |
9 |
Correct |
613 ms |
436 KB |
Output is correct |
10 |
Incorrect |
283 ms |
348 KB |
Output isn't correct |
11 |
Halted |
0 ms |
0 KB |
- |