Submission #19679539


Source Code Expand

Copy
#include<bits/stdc++.h>
using namespace std ;


#define vt vector
#define all(c) (c).begin(), (c).end()
#define sz(x) (int)(x).size()
#define ll long long
#define ld long double
#define ar array
#define inf() ifstream cin("d.txt")
#define onf() ofstream cout("test.txt")
#define mod 1000000007
#define pb push_back
#define endl cout<<"\n";
#define prt1(a) cout<<a<<" "
#define prt2(a,b) cout<<a<<" "<<b<<" "
#define prt3(a,b,c) cout<<a<<" "<<b<<" "<<c<<" "
#define in(a) cin>>a
#define inn(a,b) cin>>a>>b
#define innn(a,b,c) cin>>a>>b>>c 
#define rep(i,st,end) for(ll i=st;i<end;i++)
#define repv(i,st,end) for(ll i=st;i>=end;i--)
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define TEST ll tc;cin>>tc;while(tc--)
#define EACH(x, a) for (auto& x: a)

template<class A> void read(vt<A>& v);
template<class A, size_t S> void read(ar<A, S>& a);
template<class T> void read(T& x) {
    cin >> x;
}
void read(double& d) {
    string t;
    read(t);
    d=stod(t);
}
void read(long double& d) {
    string t;
    read(t);
    d=stold(t);
}
template<class H, class... T> void read(H& h, T&... t) {
    read(h);
    read(t...);
}
template<class A> void read(vt<A>& x) {
    EACH(a, x)
        read(a);
}
template<class A, size_t S> void read(array<A, S>& x) {
    EACH(a, x)
        read(a);
}
#define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a <<"\n";
    err(++it, args...);
}


void solve()
{
    ll n;
    read(n);
    vt<ll>v(n);
    read(v);
    ll sum = 0  ;
    rep(i,0,n)
    sum+=v[i] ;

    vt<ll>dp(sum+1,0) ;
    dp[0] =  1;
    rep(i,0,n)
    {
        repv(j,sum,0)
        {
            if(j-v[i] >=0 and dp[j-v[i]])
                dp[j]= 1 ;
        }
    }
    ll ans =0 ;
    rep(i,0,sum+1)
    if(dp[i])
        ans++ ;

    cout<<ans ;

}

 int main()
 {
    clock_t start, end; 
    start = clock(); 
    fio;
    ll k = 1;
    ll tc = 1;
    cin>>tc;
    while(tc--){
       // cout<<"Case #"<<k<<": ";k++;
        solve();
        endl;
    }
    end = clock();
     double time_taken = double(end - start) / double(CLOCKS_PER_SEC); 
    // debug(time_taken);
    
 }


Submission Info

Submission Time
Task A - コンテスト
User IOOHAN
Language C++ (GCC 9.2.1)
Score 0
Code Size 2511 Byte
Status WA
Exec Time 8 ms
Memory 3616 KB

Compile Error

./Main.cpp: In function ‘void err(std::istream_iterator<std::__cxx11::basic_string<char> >)’:
./Main.cpp:58:35: warning: unused parameter ‘it’ [-Wunused-parameter]
   58 | void err(istream_iterator<string> it) {}
      |          ~~~~~~~~~~~~~~~~~~~~~~~~~^~
./Main.cpp: In function ‘int main()’:
./Main.cpp:100:8: warning: unused variable ‘k’ [-Wunused-variable]
  100 |     ll k = 1;
      |        ^
./Main.cpp:109:13: warning: unused variable ‘time_taken’ [-Wunused-variable]
  109 |      double time_taken = double(end - start) / double(CLOCKS_PER_SEC);
      |             ^~~~~~~~~~

Judge Result

Set Name All
Score / Max Score 0 / 2
Status
WA × 5
Set Name Test Cases
All 00, 01, 02, 90, 91
Case Name Status Exec Time Memory
00 WA 8 ms 3608 KB
01 WA 3 ms 3616 KB
02 WA 4 ms 3504 KB
90 WA 2 ms 3604 KB
91 WA 3 ms 3484 KB