Submission #65792


ソースコード

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
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,x,n) for(int i=(x);i<=(n);i++)
#define rrep(i,n,x) for(int i=(n);i>=(x);i--)
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vb vector<bool>
#define all(v) v.begin(),v.end()
#define fi first
#define se second
int main(){
cin.tie(nullptr);
ios_base::sync_with_stdio(false);
int n,k; cin>>n>>k;
vi a(n);
bool flag=false;
rep(i,0,n-1) cin>>a[i];
rep(bit,1,(1<<n)-1){
int sum=0;
rep(i,0,n-1){
if(bit&(1<<i)){
sum+=a[i];
}
}
if(sum==k){
flag=true;
}
}
if(flag) cout<<"OK"<<"\n";
else cout<<"NG"<<"\n";
return 0;
}

ステータス

項目 データ
問題 0064 - 足し算できる?
ユーザー名 ei2005
投稿日時 2021-02-10 17:28:35
言語 C++14
状態 Accepted
得点 5
ソースコード長 809 Byte
最大実行時間 73 ms
最大メモリ使用量 604 KB

セット

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

テストケース

ファイル名 状態 実行時間 メモリ使用量 #
AddInput1.txt AC 58 ms 604 KB
1
AddInput2.txt AC 20 ms 428 KB
1
AddInput3.txt AC 34 ms 508 KB
1
AddInput4.txt AC 73 ms 588 KB
1
AddInput5.txt AC 36 ms 540 KB
1
AddInput6.txt AC 24 ms 496 KB
1