結果
| 問題 |
No.4 おもりと天秤
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-10-30 00:58:24 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 954 bytes |
| コンパイル時間 | 902 ms |
| コンパイル使用メモリ | 98,076 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-10-07 13:15:54 |
| 合計ジャッジ時間 | 2,607 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 15 RE * 8 |
ソースコード
#include <iostream>
#include <utility>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
using namespace std;
using ll = long long int;
#define chmax(x,y) (x) = ((x) > (y)) ? (x) : ((x) = (y));
#define chmin(x,y) (x) = ((x) < (y)) ? (x) : ((x) = (y));
const int INF = 1e9;
const ll INFL = 1e18;
const int Mod = 1e9 + 7;
const int dx[] = {0,1,0,-1};
const int dy[] = {1,0,-1,0};
int main(int argc, char const *argv[])
{
int N; cin >> N;
vector<int> W(N); for(auto &a: W)cin >> a;
vector<vector<int>> dp(N+1,vector<int>(1001));
dp[0][0] = 1;
for(int i=0;i<N;++i)
{
for(int j=0;j<1000;++j)
{
if(dp[i][j])
{
dp[i+1][j+W[i]] = 1;
int x = abs(j - W[i]);
dp[i+1][x] = 1;
}
}
}
if(dp[N][0])std::cout << "possible" << std::endl;
else std::cout << "impossible" << std::endl;
}