結果

問題 No.4 おもりと天秤
ユーザー syutarosyutaro
提出日時 2017-06-24 01:37:08
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 928 bytes
コンパイル時間 704 ms
コンパイル使用メモリ 75,208 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-14 06:55:26
合計ジャッジ時間 1,868 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,816 KB
testcase_01 AC 1 ms
6,940 KB
testcase_02 AC 1 ms
6,940 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 11 ms
6,940 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 12 ms
6,940 KB
testcase_08 AC 1 ms
6,940 KB
testcase_09 WA -
testcase_10 AC 13 ms
6,944 KB
testcase_11 AC 1 ms
6,940 KB
testcase_12 AC 2 ms
6,944 KB
testcase_13 AC 1 ms
6,940 KB
testcase_14 AC 1 ms
6,944 KB
testcase_15 AC 2 ms
6,940 KB
testcase_16 WA -
testcase_17 AC 2 ms
6,940 KB
testcase_18 WA -
testcase_19 AC 10 ms
6,944 KB
testcase_20 AC 10 ms
6,944 KB
testcase_21 AC 9 ms
6,944 KB
testcase_22 AC 9 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cstdio>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <set>
#define rep(i, n) for(int (i)=0; (i)<(n); ++(i))
using namespace std;

int main()
{
    int n;
    cin >> n;
    int w[100];
    map<int, bool> m;
    m[0] = true;
    int sum = 0;
    rep(i, n) {
        cin >> w[i];
        sum += w[i];
    }

    if(sum % 2 ==  1) {
        cout << "impossible" << endl;
	    return 0;
    }

    rep(i, n) {
        map<int, bool> mm;
        for(map<int, bool>::iterator itr = m.begin(); itr != m.end(); ++itr) {
            if(i + itr->first ==  sum / 2) {
                cout << "possible" << endl;
                return 0;
            }
            mm[i + itr->first] = true;
        }

        for(map<int, bool>::iterator itr = mm.begin(); itr != mm.end(); ++itr) {
            m[itr->first] = true;
        }
    }

    cout << "impossible" << endl;
	return 0;
}
0