Submission #39389


ソースコード

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
45
46
47
48
49
50
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <cstring>
#include <algorithm>
#include <vector>
//#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <functional>
using namespace std;
#define elif else if
#define echo cout <<
#define read cin >>
#define then {
#define elsee else {
#define _do {
#define done }
#define fi }
#define fin << '\n'
#define finn cout << '\n'
typedef long long ll;
typedef bool boolean;
typedef pair<int,int> pii;
typedef pair<pii, pii> piiii;
typedef pair<piiii, piiii> piiiiiiii;
typedef pair<piiiiiiii, piiiiiiii> piiiiiiiiiiiiiiii;
typedef pair<piiiiiiiiiiiiiiii, piiiiiiiiiiiiiiii> piiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii;
typedef pair<piiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii, piiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii> piiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii;
const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
boolean canMove(int x,int y,int w,int h){return (x>=0&&y>=0&&x<w&&y<h);};
const int INF = 1 << 29;
int numbers[120];
int n, m;
boolean dfs(int temp, int now){
if ( temp == m ) return true;
if ( now == n+1 ) return false;
return ( dfs(temp, now+1) || dfs(temp+numbers[now], now+1) );
}
int main(){
cin.tie(0); ios::sync_with_stdio(false);
read n >> m;
for ( int i = 0; i < n; i++ ) {
read numbers[i];
}
echo ( dfs(0, 0) ? "OK\n" : "NG\n" );
return 0;
}

ステータス

項目 データ
問題 0064 - 足し算できる?
ユーザー名 r1825
投稿日時 2018-07-23 11:58:07
言語 C++11
状態 Accepted
得点 5
ソースコード長 1480 Byte
最大実行時間 32 ms
最大メモリ使用量 620 KB

セット

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

テストケース

ファイル名 状態 実行時間 メモリ使用量 #
AddInput1.txt AC 23 ms 480 KB
1
AddInput2.txt AC 29 ms 440 KB
1
AddInput3.txt AC 18 ms 528 KB
1
AddInput4.txt AC 32 ms 620 KB
1
AddInput5.txt AC 26 ms 584 KB
1
AddInput6.txt AC 26 ms 544 KB
1