Submission #41166
ソースコード
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 | #include<bits/stdc++.h> #define F first #define S second using namespace std; typedef pair< int , int > P; int a[26]; int n,k; bool bfs(){ queue<P>q; q.push(P(a[0],0)); q.push(P(0,0)); while (!q.empty()){ P tmp=q.front(); q.pop(); if (tmp.F == k) return 1; if (tmp.S<n-1){ q.push(P(tmp.F+a[tmp.S+1],tmp.S+1)); q.push(P(tmp.F,tmp.S+1)); } } return 0; } int main(){ scanf ( "%d %d" ,&n,&k); for ( int i=0;i<n;++i) scanf ( "%d" ,&a[i]); if (bfs()) printf ( "OK\n" ); else printf ( "NG\n" ); return 0; } |
ステータス
項目 | データ |
---|---|
問題 | 0064 - 足し算できる? |
ユーザー名 | crom |
投稿日時 | 2018-08-10 20:17:16 |
言語 | C++11 |
状態 | Accepted |
得点 | 5 |
ソースコード長 | 558 Byte |
最大実行時間 | 42 ms |
最大メモリ使用量 | 9100 KB |
セット
セット | 得点 | Cases | |
---|---|---|---|
1 | ALL | 5 / 5 | * |
テストケース
ファイル名 | 状態 | 実行時間 | メモリ使用量 | # |
---|---|---|---|---|
AddInput1.txt | AC | 27 ms | 480 KB |
1
|
AddInput2.txt | AC | 17 ms | 448 KB |
1
|
AddInput3.txt | AC | 17 ms | 552 KB |
1
|
AddInput4.txt | AC | 42 ms | 9100 KB |
1
|
AddInput5.txt | AC | 21 ms | 580 KB |
1
|
AddInput6.txt | AC | 30 ms | 544 KB |
1
|