結果

問題 No.4 おもりと天秤
ユーザー rnanornano
提出日時 2023-01-26 21:24:31
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 7 ms / 5,000 ms
コード長 1,285 bytes
コンパイル時間 1,434 ms
コンパイル使用メモリ 164,932 KB
実行使用メモリ 22,100 KB
最終ジャッジ日時 2023-09-09 20:01:00
合計ジャッジ時間 2,633 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
5,604 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 4 ms
13,904 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 4 ms
11,692 KB
testcase_08 AC 6 ms
22,096 KB
testcase_09 AC 4 ms
11,640 KB
testcase_10 AC 4 ms
11,648 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 7 ms
22,100 KB
testcase_19 AC 4 ms
11,636 KB
testcase_20 AC 3 ms
11,576 KB
testcase_21 AC 4 ms
11,588 KB
testcase_22 AC 4 ms
11,648 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define rrep(i,n) for (int i = (int)(n-1); i >= 0; --i)
#define Rep(i,a,b) for (int i = a; i < b; ++i)
#define rRep(i,a,b) for (int i = a; i > b; --i)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define Bit(x,i) (((x)>>(i))&1)
using ll = long long;
using vi = vector<int>;
using vll = vector<long long>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const double PI = acos(-1);
const int INF = 1e9+2;
const ll LINF = 3e18;

int W[110];
bool dp[110][200100];

int main() {
  int N; cin >> N;
  int sum = 0;
  rep(i, N) {
    cin >> W[i];
    sum += W[i];
  }
  dp[0][0] = true;
  rep(i, N) {
    rep(j, sum+1) {
      if(!dp[i][j]) continue;
      dp[i+1][j] = true;
      dp[i+1][j+W[i]] = true;
      if(j+W[i] == sum-j-W[i]) {
        cout << "possible" << endl;
        return 0;
      }
    }
  }
  cout << "impossible" << endl;
}
0