結果
問題 |
No.4 おもりと天秤
|
ユーザー |
|
提出日時 | 2015-07-08 13:15:38 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,035 bytes |
コンパイル時間 | 487 ms |
コンパイル使用メモリ | 56,772 KB |
実行使用メモリ | 10,144 KB |
最終ジャッジ日時 | 2024-07-08 01:41:40 |
合計ジャッジ時間 | 7,071 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 5 TLE * 1 -- * 17 |
ソースコード
// // main.cpp // Q19 // // Created by AkihiroKOBAYASHI on 7/6/15. // Copyright (c) 2015 Akhr5884. All rights reserved. // #include <iostream> int *w; int sum; int n; int check; void judge(int nowWeight, int nowNumber) { if(nowNumber == n) { if(nowWeight == sum-nowWeight) { check = 1; return; } else { return; } } else { // add judge(nowWeight, nowNumber + 1); // not add judge(nowWeight + w[nowNumber], nowNumber + 1); } return; } int main(int argc, const char * argv[]) { std::cin >> n; w = (int*)malloc(sizeof(w) * n); int count = 0; sum = 0; while (count < n) { int wi; std::cin >> wi; w[count] = wi; sum += wi; count++; } check = 0; judge(0, 0); if(check == 1) { std::cout << "possible" << "\n"; } else { std::cout << "impossible" << "\n"; } return 0; }