Submission #79849


ソースコード

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

ステータス

項目 データ
問題 1221 - bit全探索(基本)
ユーザー名 ei2423
投稿日時 2024-07-11 17:39:02
言語 C++17
状態 Accepted
得点 1
ソースコード長 665 Byte
最大実行時間 384 ms
最大メモリ使用量 716 KB

セット

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

テストケース

ファイル名 状態 実行時間 メモリ使用量 #
in01.text AC 25 ms 604 KB
1
in02.text AC 24 ms 452 KB
1
in03.text AC 20 ms 428 KB
1
in04.text AC 21 ms 396 KB
1
in05.text AC 26 ms 492 KB
1
in06.text AC 21 ms 324 KB
1
in07.text AC 20 ms 672 KB
1
in08.text AC 345 ms 632 KB
1
in09.text AC 375 ms 716 KB
1
in10.text AC 384 ms 540 KB
1