結果
| 問題 |
No.545 ママの大事な二人の子供
|
| コンテスト | |
| ユーザー |
mban
|
| 提出日時 | 2017-07-14 22:53:34 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 794 bytes |
| コンパイル時間 | 909 ms |
| コンパイル使用メモリ | 97,452 KB |
| 実行使用メモリ | 10,496 KB |
| 最終ジャッジ日時 | 2024-10-07 23:46:31 |
| 合計ジャッジ時間 | 5,027 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 22 TLE * 1 -- * 9 |
ソースコード
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <time.h>
#include <vector>
using namespace std;
#define ll long long
int N;
std::vector<int> a, b;
ll dfs(ll aa, ll bb, int n) {
if (n == N) {
return abs(aa - bb);
}
ll aaa = dfs(aa + a[n], bb, n + 1);
ll baa = dfs(aa, bb + b[n], n + 1);
return min(aaa, baa);
}
int main() {
cin >> N;
a = std::vector<int>(N);
b = std::vector<int>(N);
for (size_t i = 0; i < N; i++) {
cin >> a[i] >> b[i];
}
cout << dfs(0, 0, 0) << endl;
return 0;
}
mban