-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path3752.cpp
More file actions
44 lines (41 loc) · 750 Bytes
/
3752.cpp
File metadata and controls
44 lines (41 loc) · 750 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// 3752. 가능한 시험 점수
// 2019.07.08
#include<iostream>
using namespace std;
int visit[10001];
int score[101];
int main()
{
int t;
cin >> t;
for (int test_case = 1; test_case <= t; test_case++)
{
int n;
cin >> n;
fill(visit, visit + 10001, 0);
int count = 0;
visit[0] = 1; // 0점은 가능
count++;
int sum = 0;
for (int i = 0; i < n; i++)
{
cin >> score[i];
}
for (int i = 0; i < n; i++)
{
int curScore = score[i];
for (int j = sum; j >= 0; j--)
{
// 가능한 시험점수라면 true로
if (visit[j] && !visit[j + curScore])
{
count++; // 개수 증가
visit[j + curScore] = true;
}
}
sum += curScore;
}
printf("#%d %d\n", test_case, count);
}
return 0;
}