結果
問題 |
No.2840 RGB Plates
|
ユーザー |
|
提出日時 | 2024-08-09 23:41:09 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 602 bytes |
コンパイル時間 | 4,000 ms |
コンパイル使用メモリ | 255,116 KB |
最終ジャッジ日時 | 2025-02-23 22:12:53 |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 2 TLE * 1 -- * 25 |
ソースコード
#include <bits/stdc++.h> using namespace std; #include<atcoder/all> using namespace atcoder; using ll = long long; const ll mod=998244353; using BS=bitset<15000010>; int main() { ll N; cin>>N; vector<ll> A(N); for(ll &a:A)cin>>a; sort(A.begin(),A.end()); BS B; B[0]=1; ll an=1e18; ll S=0; for(int i=0;i<N;i++){ S+=A[i]; BS NB=B; NB<<=A[i]; // cout<<NB<<endl; BS P=NB&B; if(P.any()){ an=min(an,ll(P._Find_first())); } B=NB|B; } cout<<(an<1e18&&S-2*an>0?S-2*an:-1)<<endl; }