Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
35066 | LYLAKIOIAKIOI | 【S】T1 | C++ | 通过 | 100 | 1130 MS | 262400 KB | 589 | 2024-11-26 15:28:23 |
#include<bits/stdc++.h> #define ll long long using namespace std; const int N=50,S=3.5e7,inf=1e9+10; int f[S]; int n;ll a[N]; #define lb(x) (x&(-x)) int main(){ cin>>n;for(int i=1;i<=n;i++) cin>>a[i]; for(int i=n+1;i>=1;i--) a[i]=a[i]-a[i-1]; int tot=1<<(n+1); for(int i=1;i<tot;i++){ ll sm=0; int st=i; while(st!=0){ int x=__builtin_ctz(lb(st))+1; f[i]=max(f[i],f[i^lb(st)]); sm+=a[x];st-=lb(st); }if(sm==0) f[i]++;//cout<<i<<' '<<f[i]<<endl; }cout<<n+1-f[tot-1]; return 0; }