結果

問題 No.4 おもりと天秤
ユーザー char134217728char134217728
提出日時 2017-08-19 02:25:39
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 108 ms / 5,000 ms
コード長 730 bytes
コンパイル時間 1,223 ms
コンパイル使用メモリ 150,732 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-08 17:33:55
合計ジャッジ時間 2,917 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,384 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 3 ms
4,380 KB
testcase_05 AC 93 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 99 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 108 ms
4,380 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 45 ms
4,376 KB
testcase_19 AC 85 ms
4,380 KB
testcase_20 AC 85 ms
4,380 KB
testcase_21 AC 80 ms
4,376 KB
testcase_22 AC 85 ms
4,380 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:16:6: warning: ISO C++ forbids declaration of ‘main’ with no type [-Wreturn-type]
 main(){
      ^

ソースコード

diff #

#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef set<int> si;
const int inf = 1e9;
const int mod = 1e9+7;

int n;
si sn, st;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  st.insert(0);
  FOR(i, 0, n){
    int w;
    cin >> w;
    for(si::iterator itr = st.begin(); itr != st.end(); itr++){
      sn.insert(w + *itr);
      sn.insert(w - *itr);
      sn.insert(*itr - w);
      sn.insert(0 - *itr - w);
    }
    swap(st, sn);
    sn.clear();
  }
  cout << (st.find(0) == st.end() ? "im" : "") << "possible" << endl;
}
0