結果

問題 No.3534 Make Many Fences
コンテスト
ユーザー t98slider
提出日時 2026-05-08 21:28:54
言語 C++23
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 40 ms / 1,000 ms
コード長 537 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,748 ms
コンパイル使用メモリ 332,928 KB
実行使用メモリ 7,972 KB
最終ジャッジ日時 2026-05-08 21:29:05
合計ジャッジ時間 4,126 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 9
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int T;
    cin >> T;
    while(T--){
        ll n, m;
        cin >> n >> m;
        ll ok = 0, ng = 1ll << 40;
        while(ok + 1 < ng){
            ll mid = (ok + ng) / 2;
            ll d = (mid + 2) / 3;
            ll B = max(0ll, d * 2 - m);
            while(B % 4 != 0) B++;
            ll W = B / 2 + d * 4;
            (n >= W ? ok : ng) = mid;
        }
        cout << ok << '\n';
    }
}
0