結果
| 問題 |
No.4 おもりと天秤
|
| コンテスト | |
| ユーザー |
h_noson
|
| 提出日時 | 2016-02-16 23:00:33 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 639 bytes |
| コンパイル時間 | 668 ms |
| コンパイル使用メモリ | 56,408 KB |
| 最終ジャッジ日時 | 2024-11-14 19:34:09 |
| 合計ジャッジ時間 | 1,074 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:17:15: error: ‘accumulate’ was not declared in this scope
17 | int sum = accumulate(w.begin(),w.end(),0);
| ^~~~~~~~~~
ソースコード
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define REPR(i,s,e) for (int i = e-1; i >= s; i--)
#define repr(i,n) REPR(i,0,n)
#define REP(i,s,e) for (int i = s; i < e; i++)
#define rep(i,n) REP(i,0,n)
int main() {
int n;
cin >> n;
vector<int> w(n);
rep(i,n) cin >> w[i];
int sum = accumulate(w.begin(),w.end(),0);
vector<bool> dp(sum+1);
dp[0] = true;
rep(i,n) repr(j,sum+1) {
if (dp[j])
dp[j+w[i]] = true;
}
if (sum % 2 == 0 && dp[sum/2])
cout << "possible" << endl;
else
cout << "impossible" << endl;
return 0;
}
h_noson