Submission #17506977


Source Code Expand

Copy
/*
g++ --std=c++17 A.cpp
*/

#include <iostream>
#include <iomanip> //! for setprecision(20)
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>
#include <limits.h>

using namespace std;

typedef long long LL;

#define rep(i,n) for (int i = 0; i < int(n); ++i)
#define repr(i,from,to) for (int i = int(from); i <= int(to); ++i)

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }

#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define dumpMap(m) { for (auto it: m) cout << it.first << "=>" << it.second << ' '; }

typedef pair<int, int> P;
#define F first
#define S second

const int INF = 1e9;
const LL INFL = 1e18;
const int MOD = 1000000007;

// int dx[] = { 0, -1, 1, 0 };
// int dy[] = { -1, 0, 0, 1 };

// int dx[] = { -1, 0, 1, -1, 1, -1, 0, 1 };
// int dy[] = { -1, -1, -1, 0, 0, 1, 1, 1 };


int main()
{
  cin.tie(0);
  ios::sync_with_stdio(0);

  int n;
  cin >> n;

  vector<bool> curr(100*n+1);
  curr[0] = true;
  rep(i, n) {
    vector<bool> next(100*n+1);
    int p;
    cin >> p;
    int prevMax = i * 100;
    rep(pp, prevMax+1) {
      next[pp] = next[pp] || curr[pp];
      if (curr[pp]) {
        next[pp+p] = true;
      }
    }
    curr.swap(next);
  }

  int ans = 0;
  rep(i, 100*n+1) {
    if (curr[i]) ++ans;
  }

  cout << ans << endl;

  return 0;
}

Submission Info

Submission Time
Task A - コンテスト
User nobukichi
Language C++ (GCC 9.2.1)
Score 2
Code Size 1725 Byte
Status
Exec Time 7 ms
Memory 3612 KB

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 7 ms 3612 KB
01 4 ms 3568 KB
02 6 ms 3584 KB
90 4 ms 3452 KB
91 1 ms 3612 KB