Submission #74401


ソースコード

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)) !=0){
sum+= a[i];
}
}
ans.insert(sum);
}
for(auto itr=ans.begin(); itr!= ans.end(); itr++){
cout<<*itr<<"\n";
}
return (0);
}

ステータス

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

セット

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

テストケース

ファイル名 状態 実行時間 メモリ使用量 #
in01.text AC 27 ms 604 KB
1
in02.text AC 28 ms 580 KB
1
in03.text AC 18 ms 420 KB
1
in04.text AC 21 ms 512 KB
1
in05.text AC 22 ms 480 KB
1
in06.text AC 23 ms 568 KB
1
in07.text AC 20 ms 532 KB
1
in08.text AC 102 ms 500 KB
1
in09.text AC 98 ms 588 KB
1
in10.text AC 105 ms 548 KB
1