1 solutions

  • 0
    @ 2023-2-10 13:31:45

    自学一下bitset就可以看懂了

    #include <bits/stdc++.h>
    using namespace std;
    #define accelerate ios::sync_with_stdio(false),cin.tie(0);
    #define int long long
    #define PII pair<int,int>
    #define mod 1000000007
    #define ufor(i,st,en) for(int i=st;i<=en;i++)
    #define dfor(i,en,st) for(inNt i=en;i>=st;i--)
    const int N = 1e6 + 10;
    const int INF = 1e15;
    int n, m, k, x, y, xx, yy, T, q, S;
    bitset<N>s;
    signed main(){
    	accelerate;
    	cin>>n;
    	cin>>x;
    	s[x]=1;
    	ufor(i,2,n){
    		cin>>x;
    		s|=s<<x;
    		s[x]=1;
    	}
    	cout<<s.count();
    	return 0;
    }

    Information

    ID
    6635
    Time
    1000ms
    Memory
    256MiB
    Difficulty
    9
    Tags
    (None)
    # Submissions
    26
    Accepted
    4
    Uploaded By