結果

問題 No.2840 RGB Plates
コンテスト
ユーザー みここ
提出日時 2024-08-09 22:51:40
言語 C++17
(gcc 15.2.0 + boost 1.90.0)
コンパイル:
g++-15 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
(最新)
TLE  
(最初)
実行時間 1,577 ms / 2,000 ms
コード長 513 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 348 ms
コンパイル使用メモリ 84,576 KB
実行使用メモリ 16,640 KB
最終ジャッジ日時 2026-07-05 11:18:11
合計ジャッジ時間 25,171 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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

bitset<8000001> b;
bitset<8000001> e;
bitset<8000001> 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