結果
| 問題 |
No.4 おもりと天秤
|
| コンテスト | |
| ユーザー |
cww
|
| 提出日時 | 2017-04-20 17:47:23 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
RE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 785 bytes |
| コンパイル時間 | 2,245 ms |
| コンパイル使用メモリ | 171,740 KB |
| 実行使用メモリ | 7,296 KB |
| 最終ジャッジ日時 | 2024-12-26 05:01:02 |
| 合計ジャッジ時間 | 5,842 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | RE * 23 |
コンパイルメッセージ
main.cpp: In function 'bool memo(int, int)':
main.cpp:22:13: warning: control reaches end of non-void function [-Wreturn-type]
22 | memo( i + 1, total );
| ~~~~^~~~~~~~~~~~~~~~
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
vector<vector<int>> visited( 100 + 1, vector<int>( 10000 + 1, 0 ) );
vector<int> w;
int N, total;
bool memo( int i, int total )
{
if( visited[ i ][ total ] )
{
return visited[ i ][ total ];
}
if( i == N )
{
return 0;
}
visited[ i ][ total ] = 1;
memo( i + 1, total + w[ i ] );
memo( i + 1, total );
}
int main()
{
cin >> N;
w.resize( N );
for( auto &x : w )
{
cin >> x;
}
total = accumulate( ALL( w ), 0 );
memo( 0, 0 );
cout << ( visited[ N - 1 ][ total / 2 ] && total % 2 == 0 ? "possible" : "impossible" ) << endl;
return 0;
}
cww