Submission #1002912

#TimeUsernameProblemLanguageResultExecution timeMemory
1002912CabralbonzaoCigle (COI21_cigle)C++17
9 / 100
641 ms444 KiB
#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; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...