結果

問題 No.2840 RGB Plates
ユーザー みここ
提出日時 2024-08-09 22:50:55
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
実行時間 -
コード長 516 bytes
コンパイル時間 668 ms
コンパイル使用メモリ 69,716 KB
最終ジャッジ日時 2025-02-23 21:58:27
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 2 TLE * 1 -- * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <bitset>
using namespace std;

bitset<15000001> b;
bitset<15000001> e;
bitset<15000001> c;

int main()
{
    int n;
    cin >> n;
    b.set(0, true);
    int s = 0;
    for (int i = 0; i < n; i++)
    {
        int a;
        cin >> a;
        s += a;
        c = b << a;
        e |= b & c;
        b |= c;
    }
    for (int i = 1; i * 2 < s; i++)
    {
        if (e[i])
        {
            cout << s - i * 2 << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}
0