[SWEA] 3752 가능한 시험 점수

Time Lapse :23min 32sec

3752.c

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <stdio.h>
#include <memory.h>
int v[10001];
int input;
int ans, N;
int main(void) {
int tc = 0, T;
scanf("%d", &T);
while (T--) {
scanf("%d", &N);
ans = 0;
memset(v, 0, sizeof(v));
v[0] = 1;
for (int i = 0; i < N; ++i) {
scanf("%d", &input);
for (int j = 10000; j >= 0; --j) {
if (v[j]) v[j + input] = 1;
}
}
for (int i = 0; i <= 10000; ++i)
if (v[i]) ++ans;
printf("#%d %d\n", ++tc, ans);
}
}
Author: Song Hayoung
Link: https://songhayoung.github.io/2020/08/04/PS/SWEA/3752/
Copyright Notice: All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.