Submission #74373


ソースコード

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
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
int a[n];
for (int i = 0; i < n; i++) {
cin >> a[i];
}
set<int> ans;
for (int bit = 1; bit < (1 << n); bit++) {
int sum = 0;
for (int i = 0; i < n; i++) {
if (bit & (1 << i)) {
sum += a[i];
}
}
ans.insert(sum);
}
for (auto itr = ans.begin(); itr != ans.end(); itr++) {
cout << *itr << "\n";
}
return(0);
}

ステータス

項目 データ
問題 1221 - bit全探索(基本)
ユーザー名 woody_1227
投稿日時 2023-07-10 17:24:29
言語 C++17
状態 Accepted
得点 1
ソースコード長 538 Byte
最大実行時間 106 ms
最大メモリ使用量 640 KB

セット

セット 得点 Cases
1 ALL 1 / 1 *

テストケース

ファイル名 状態 実行時間 メモリ使用量 #
in01.text AC 22 ms 604 KB
1
in02.text AC 17 ms 444 KB
1
in03.text AC 17 ms 540 KB
1
in04.text AC 25 ms 628 KB
1
in05.text AC 25 ms 584 KB
1
in06.text AC 23 ms 544 KB
1
in07.text AC 23 ms 504 KB
1
in08.text AC 92 ms 464 KB
1
in09.text AC 106 ms 424 KB
1
in10.text AC 96 ms 640 KB
1