結果

問題 No.3534 Make Many Fences
コンテスト
ユーザー nauclhlt
提出日時 2026-03-04 15:04:43
言語 C++17
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 82 ms / 1,000 ms
コード長 737 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,771 ms
コンパイル使用メモリ 212,084 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2026-05-08 20:50:48
合計ジャッジ時間 5,104 ms
ジャッジサーバーID
(参考情報)
judge2_1 / 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(nullptr);

    int T;
    cin >> T;
    assert(1 <= T && T <= 100000);
    while (T--)
    {
        ll N, M;
        cin >> N >> M;

        assert(0 <= N && N <= 1000000000LL);
        assert(0 <= M && M <= 1000000000LL);

        if (N % 2 == 1) N--;
        if (M % 2 == 1) M--;

        if (N < 2 * M)
        {
            cout << (3 * (N / 4)) << endl;
        }
        else
        {
            ll ans = 3 * (M / 2);
            N -= 2 * M;
            M = 0;
            ans += 6 * (N / 10);
            N %= 10;
            if (6 <= N) ans += 3;

            cout << ans << endl;
        }
    }
}
0