Submission #1644480


Source Code Expand

#include <cstdio>
#include <cassert>
#include <cmath>
#include <cstring>

#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <stack>
#include <queue>

#include <tuple>

#define getchar getchar_unlocked
#define putchar putchar_unlocked

#define _rep(_1, _2, _3, _4, name, ...) name
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, b) rep4(i, a, b, 1)
#define rep4(i, a, b, c) for (int i = int(a); i < int(b); i += int(c))
#define rep(...) _rep(__VA_ARGS__, rep4, rep3, rep2, _)(__VA_ARGS__)

using namespace std;

using i64 = long long;
using u8 = unsigned char;
using u32 = unsigned;
using u64 = unsigned long long;
using f80 = long double;

int get_int() {
  int c, n;
  while ((c = getchar()) < '0');
  n = c - '0';
  while ((c = getchar()) >= '0') n = n * 10 + (c - '0');
  return n;
}

void solve() {
  int N;
  while (~scanf("%d", &N)) {
    vector<int> counts(N * 100 + 1, 0); counts[0] = 1;
    int s = 0;
    rep(i, N) {
      int a = get_int();
      for (int j = s; j >= 0; --j) counts[j + a] |= counts[j];
      s += a;
    }
    int ans = 0;
    for (auto& a : counts) ans += a;
    printf("%d\n", ans);
  }
}

int main() {
  // clock_t beg = clock();
  solve();
  // clock_t end = clock();
  // fprintf(stderr, "%.3f sec\n", double(end - beg) / CLOCKS_PER_SEC);
  return 0;
}

Submission Info

Submission Time
Task A - コンテスト
User Min_25
Language C++14 (GCC 5.4.1)
Score 2
Code Size 1425 Byte
Status AC
Exec Time 1 ms
Memory 256 KB

Judge Result

Set Name All
Score / Max Score 2 / 2
Status
AC × 5
Set Name Test Cases
All 00, 01, 02, 90, 91
Case Name Status Exec Time Memory
00 AC 1 ms 256 KB
01 AC 1 ms 256 KB
02 AC 1 ms 256 KB
90 AC 1 ms 256 KB
91 AC 1 ms 256 KB