結果

問題 No.545 ママの大事な二人の子供
ユーザー mbanmban
提出日時 2017-07-14 22:53:34
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 794 bytes
コンパイル時間 910 ms
コンパイル使用メモリ 96,892 KB
実行使用メモリ 8,704 KB
最終ジャッジ日時 2024-04-16 20:38:16
合計ジャッジ時間 4,936 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
8,576 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 AC 3 ms
5,376 KB
testcase_18 AC 16 ms
5,376 KB
testcase_19 AC 56 ms
5,376 KB
testcase_20 AC 218 ms
5,376 KB
testcase_21 AC 2 ms
5,376 KB
testcase_22 TLE -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0