Submission #40995
ソースコード
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 | #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 fin << '\n' #define finn cout << '\n' #define ifin << endl typedef long long llong; typedef bool boolean; typedef pair< int , int > pii; 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 a[32], n, k; boolean dfs( int now, int sum){ if ( sum == k ) return true ; if ( now == n ) return false ; return dfs( now + 1, sum ) || dfs( now + 1, sum + a[now] ); } signed main(){ cin.tie(0); ios::sync_with_stdio( false ); read n >> k; for ( int i= 0; i < n; i++ ) { int d; read d; a[i] = abs (d); } echo ( dfs(0, 0) ? "OK" : "NG" ) fin; return 0; } |
ステータス
項目 | データ |
---|---|
問題 | 0491 - 印刷ミス |
ユーザー名 | r1825 |
投稿日時 | 2018-08-09 11:55:30 |
言語 | C++14 |
状態 | Accepted |
得点 | 1 |
ソースコード長 | 1088 Byte |
最大実行時間 | 44 ms |
最大メモリ使用量 | 488 KB |
セット
セット | 得点 | Cases | |
---|---|---|---|
1 | ALL | 1 / 1 | * |
テストケース
ファイル名 | 状態 | 実行時間 | メモリ使用量 | # |
---|---|---|---|---|
input1.txt | AC | 44 ms | 480 KB |
1
|
input2.txt | AC | 27 ms | 440 KB |
1
|
input3.txt | AC | 19 ms | 400 KB |
1
|
input4.txt | AC | 17 ms | 488 KB |
1
|