Submission #44820
ソースコード
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 | #include <bits/stdc++.h> using namespace std; #define FOR(i,n) for(int i=0;i<n;i++) #define why(n,x) int n;while(cin >>n,n!=x) #define iFOR(i,x,n)for(int i=x;i<n;i++) #define unless(flg) if ( !(flg) ) #define read cin<< #define echo cout<< #define fin <<'\n' #define __ <<" "<< #define bash push_back #define alles(x) x.begin(),x.end() #define SWAP(a,b) ((a != b) && (a += b,b = a - b,a -= b)) int dx[]={1,0,-1,0,1,1,-1,-1}; int dy[]={0,-1,0,1,-1,1,-1,1}; const int INF=1 << 30; bool inside( int x, int y, int w, int h){ return (x>=0 && y>=0 && x<w && y<h);} typedef long long ll; typedef pair< int , int > pii; typedef vector< int > vit; typedef map<string, int > mstit; typedef priority_queue< int > pqit; int n,m; int s[40]; int mem[50]; bool num( int n, int ans){ if (n < 0 || ans < 0 ) return false ; if (ans == 0) return true ; return num(n-1 ,ans) | num(n-1 ,ans-s[n-1]); } int main(){ cin.tie(0), ios::sync_with_stdio( false ); cin >>n>>m; FOR(i,n) cin >>s[i]; if (num(n,m)) cout << "OK\n" ; else cout << "NG\n" ; return 0; } |
ステータス
項目 | データ |
---|---|
問題 | 0064 - 足し算できる? |
ユーザー名 | ei1821 |
投稿日時 | 2018-11-13 12:30:04 |
言語 | C++14 |
状態 | Accepted |
得点 | 5 |
ソースコード長 | 1079 Byte |
最大実行時間 | 43 ms |
最大メモリ使用量 | 644 KB |
セット
セット | 得点 | Cases | |
---|---|---|---|
1 | ALL | 5 / 5 | * |
テストケース
ファイル名 | 状態 | 実行時間 | メモリ使用量 | # |
---|---|---|---|---|
AddInput1.txt | AC | 43 ms | 604 KB |
1
|
AddInput2.txt | AC | 25 ms | 564 KB |
1
|
AddInput3.txt | AC | 38 ms | 524 KB |
1
|
AddInput4.txt | AC | 22 ms | 476 KB |
1
|
AddInput5.txt | AC | 29 ms | 560 KB |
1
|
AddInput6.txt | AC | 23 ms | 644 KB |
1
|