Submission #17504109


Source Code Expand

Copy
#include <bits/stdc++.h>
#include <algorithm>
// #include <atcoder/all>
#include <functional>
#include <map>
#include <queue>
#include <set>
#include <stack>
using namespace std;
// using namespace atcoder;
using ll = long long;
using ull = unsigned long long;
#define REP(i, m, n) for (ll(i) = (ll)(m); i < (ll)(n); ++i)
#define REP2(i, m, n) for (ll(i) = (ll)(n)-1; i >= (ll)(m); --i)
#define rep(i, n) REP(i, 0, n)
#define rep2(i, n) REP2(i, 0, n)
#define drep(i, n) for (ll(i) = (ll)(n); i >= 0; i--)
#define all(hoge) (hoge).begin(), (hoge).end()
#define rall(hoge) (hoge).rbegin(), (hoge).rend()
#define en '\n'
// using Edge = pair<ll, ll>;
// using Graph = vector<vector<Edge>>;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 30;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll)1e9 + 7;
// constexpr long long MOD = 998244353LL;
using ld = long double;
static const ld pi = 3.141592653589793L;
template <class T> inline void print(T x) { cout << x << '\n'; }
template <class T> bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
long long gcd(long long x, long long y) { return y ? gcd(y, x % y) : x; }
long long lcm(long long x, long long y) { return x / gcd(x, y) * y; }

// kokokaradesuyo
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n; cin >> n;
    vector<ll> p(n);
    rep(i,n) cin >> p[i];
    vvl dp(n+1,vl(10200,0LL));
    dp[0][0] = 1;
    rep(i,n) {
        rep(j,10000) {
            if (dp[i][j] > 0) {
                dp[i+1][j] = dp[i][j];
                dp[i+1][j+p[i]] = dp[i][j];
            }
        }
    }
    vl c(10200,0);
    rep(i,n+1) {
        rep(j,10001) {
            if (dp[i][j] > 0) c[j] = 1;
        }
    }
    ll res = 0;
    rep(i,c.size()) {
        if (c[i]) res++;
    }
    print(res);

    return 0;
}

Submission Info

Submission Time
Task A - コンテスト
User paruf
Language C++ (GCC 9.2.1)
Score 2
Code Size 2219 Byte
Status
Exec Time 13 ms
Memory 11308 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:13:29: warning: unnecessary parentheses in declaration of ‘i’ [-Wparentheses]
   13 | #define REP(i, m, n) for (ll(i) = (ll)(m); i < (ll)(n); ++i)
      |                             ^
./Main.cpp:15:19: note: in expansion of macro ‘REP’
   15 | #define rep(i, n) REP(i, 0, n)
      |                   ^~~
./Main.cpp:59:5: note: in expansion of macro ‘rep’
   59 |     rep(i,n) cin >> p[i];
      |     ^~~
./Main.cpp:13:29: warning: unnecessary parentheses in declaration of ‘i’ [-Wparentheses]
   13 | #define REP(i, m, n) for (ll(i) = (ll)(m); i < (ll)(n); ++i)
      |                             ^
./Main.cpp:15:19: note: in expansion of macro ‘REP’
   15 | #define rep(i, n) REP(i, 0, n)
      |                   ^~~
./Main.cpp:62:5: note: in expansion of macro ‘rep’
   62 |     rep(i,n) {
      |     ^~~
./Main.cpp:13:29: warning: unnecessary parentheses in declaration of ‘j’ [-Wparentheses]
   13 | #define REP(i, m, n) for (ll(i) = (ll)(m); i < (ll)(n); ++i)
      |                             ^
./Main.cpp:15:19: note: in expansion of macro ‘REP’
   15 | #define rep(i, n) REP(i, 0, n)
      |                   ^~~
./Main.cpp:63:9: note: in expansion of macro ‘rep’
   63 |         rep(j,10000) {
      |         ^~~
./Main.cpp:13:29: warning: unnecessary parentheses in declaration of ‘i’ [-Wparentheses]
   13 | #define REP(i, m, n) for (ll(i) = (ll)(m); i < (ll)(n); ++i)
      |                             ^
./Main.cpp:15:19: note: in expansion of macro ‘REP’
   15 | #define rep(i, n) REP(i, 0, n)
      |                   ^~~
./Main.cpp:71:5: note: in expansion of macro ‘rep’
   71 |     rep(i,n+1) {
      |     ^~~
./Main.cpp:13:29: warning: unnecessary parentheses in declaration of ‘j’ [-Wparentheses]
   13 | #define REP(i, m, n) for (ll(i) = (ll)(m); i < (ll)(n); ++i)
      |                             ^
./Main.cpp:15:19: note: in expansion of macro ‘REP’
   15 | #define rep(i, n) REP(i, 0, n)
      |   ...

Judge Result

Set Name All
Score / Max Score 2 / 2
Status
× 5
Set Name Test Cases
All 00, 01, 02, 90, 91
Case Name Status Exec Time Memory
00 9 ms 4092 KB
01 9 ms 7356 KB
02 13 ms 11308 KB
90 4 ms 3700 KB
91 5 ms 4172 KB