結果

問題 No.2239 Friday
コンテスト
ユーザー vjudge1
提出日時 2025-11-20 16:24:22
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,788 bytes
コンパイル時間 2,867 ms
コンパイル使用メモリ 312,700 KB
実行使用メモリ 7,848 KB
最終ジャッジ日時 2025-11-20 16:24:26
合計ジャッジ時間 3,725 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long int
template <typename T>
using ordered_set = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define ld long double
#define nl cout << "\n";
#define getunique(v)                                  \
    {                                                 \
        sort(v.begin(), v.end());                     \
        v.erase(unique(v.begin(), v.end()), v.end()); \
    }
#define forn(a, b) for (int i = a; i < b; i++)
#define __builtin_popcountll __builtin_popcountll
#define __builtin_clzll __builtin_clzll
#define __builtin_ctzll __builtin_ctzll
#define yesno(b) cout << ((b) ? "YES" : "NO");
#define pii pair<int, int>
#define mp(a, b) make_pair(a, b)
#define pb push_back
#define all(a) a.begin(), a.end()
#define vi vector<int>
#define hhh cout << "here" << endl;
#define mod1 1000000007
#define mod2 998244353
const int inf = 1e17 + 1;
#define FL(i, a, n) for (int i = a; i < n; i++)
#define FR(i, a, n) for (int i = a; i >= n; i--)
void solve()
{
    int a, b;
    cin >> a >> b;
    if (a < b)
    {
        swap(a, b);
    }
    int ans = inf;
    for (int i = 0; i <= b; i++)
    {

        // for a
        int an = i;
        int au = a - i;

        // for b
        int bn = a - au;
        int bu = b - bn;
        ans = min(ans, abs(an + bn - (au + bu)));
    }
    cout << ans;
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    int t = 1;
    // cin >> t;
    while (t--)
    {
        solve();
        nl;
    }
    return 0;
}
0