結果
問題 | No.2542 Yokan for Two |
ユーザー |
|
提出日時 | 2023-11-24 22:21:46 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 4 ms / 2,000 ms |
コード長 | 564 bytes |
コンパイル時間 | 1,812 ms |
コンパイル使用メモリ | 168,612 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-09-26 09:30:34 |
合計ジャッジ時間 | 2,484 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 40 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define int long long #define app push_back const int maxn=2e5+5; bitset<maxn> b; int32_t main() { ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); int l,n;cin>>l>>n; int a[n];for(int i=0;i<n;++i) cin>>a[i]; int s=a[0]; b[0]=1; for(int j=1;j<n;++j) { int diff=a[j]-a[j-1]; b=b | (b<<diff); } int res=l; for(int s1=0;s1<maxn;++s1) { if(b[s1]) { res=min(res,abs(l-2*(s+s1))); } } cout<<res; return 0; }