結果
| 問題 |
No.4 おもりと天秤
|
| コンテスト | |
| ユーザー |
hogeover30
|
| 提出日時 | 2015-02-10 02:55:40 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 388 bytes |
| コンパイル時間 | 685 ms |
| コンパイル使用メモリ | 51,608 KB |
| 最終ジャッジ日時 | 2024-11-14 18:59:22 |
| 合計ジャッジ時間 | 1,254 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:10:9: error: ‘vector’ was not declared in this scope
10 | vector<int> w(n);
| ^~~~~~
main.cpp:3:1: note: ‘std::vector’ is defined in header ‘<vector>’; did you forget to ‘#include <vector>’?
2 | #include <algorithm>
+++ |+#include <vector>
3 | using namespace std;
main.cpp:10:16: error: expected primary-expression before ‘int’
10 | vector<int> w(n);
| ^~~
main.cpp:11:22: error: ‘w’ was not declared in this scope
11 | for(auto& v: w) { cin>>v; s+=v; }
| ^
main.cpp:13:16: error: expected primary-expression before ‘int’
13 | vector<int> d(s+1);
| ^~~
main.cpp:14:9: error: ‘d’ was not declared in this scope
14 | d[0]=1;
| ^
main.cpp:15:68: error: ‘w’ was not declared in this scope
15 | for(int i=0;i<n;++i) for(int j=s/2;j>=0;--j) if (d[j]) d[j+w[i]]=1;
| ^
ソースコード
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
int n;
while (cin>>n) {
int s=0;
vector<int> w(n);
for(auto& v: w) { cin>>v; s+=v; }
vector<int> d(s+1);
d[0]=1;
for(int i=0;i<n;++i) for(int j=s/2;j>=0;--j) if (d[j]) d[j+w[i]]=1;
cout<<(s%2 or !d[s/2] ? "impossible" : "possible")<<endl;
}
}
hogeover30