結果
| 問題 |
No.545 ママの大事な二人の子供
|
| コンテスト | |
| ユーザー |
vjudge1
|
| 提出日時 | 2025-03-14 17:06:23 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 774 bytes |
| コンパイル時間 | 2,187 ms |
| コンパイル使用メモリ | 192,960 KB |
| 実行使用メモリ | 10,396 KB |
| 最終ジャッジ日時 | 2025-03-14 17:06:31 |
| 合計ジャッジ時間 | 7,991 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 18 WA * 2 TLE * 1 -- * 11 |
ソースコード
#include<bits/stdc++.h>
//#define int long long
using namespace std;
inline int read()
{
int x=0,f=1;char ch=getchar();
while (ch<'0'||ch>'9'){if (ch=='-') f=-1;ch=getchar();}
while (ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+ch-48;ch=getchar();}
return x*f;
}
void write(int x)
{
if(x<0)putchar('-'),x=-x;
if(x<10)putchar(x+'0');
else write(x/10),putchar(x%10+'0');
}
const int N=1e5;
const int mod=1e9+7;
int n;
struct node{
int a,b;
}w[N];
int ans=INT_MAX;
signed main(){
n=read();
for(int i=1;i<=n;i++)w[i].a=read(),w[i].b=read();
for(int i=0;i<(1<<n)-1;i++){
int x=i;
int cnt=0;
int aa=0;
int bb=0;
while(cnt<n){
if(x&1)aa+=w[++cnt].a;
else bb+=w[++cnt].b;
x>>=1;
}
ans=min(ans,abs(aa-bb));
}
cout<<ans<<"\n";
return 0;
}
vjudge1