結果

問題 No.2057 Ising Model
ユーザー t98slidert98slider
提出日時 2022-08-26 21:56:12
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 822 bytes
コンパイル時間 1,750 ms
コンパイル使用メモリ 162,940 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-21 23:59:24
合計ジャッジ時間 5,583 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 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 2 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 2 ms
5,376 KB
testcase_20 AC 2 ms
5,376 KB
testcase_21 AC 2 ms
5,376 KB
testcase_22 AC 2 ms
5,376 KB
testcase_23 WA -
testcase_24 AC 58 ms
5,376 KB
testcase_25 AC 130 ms
5,376 KB
testcase_26 AC 21 ms
5,376 KB
testcase_27 WA -
testcase_28 AC 77 ms
5,376 KB
testcase_29 AC 119 ms
5,376 KB
testcase_30 AC 117 ms
5,376 KB
testcase_31 AC 115 ms
5,376 KB
testcase_32 AC 110 ms
5,376 KB
testcase_33 AC 128 ms
5,376 KB
testcase_34 AC 129 ms
5,376 KB
testcase_35 AC 131 ms
5,376 KB
testcase_36 AC 133 ms
5,376 KB
testcase_37 AC 133 ms
5,376 KB
testcase_38 AC 128 ms
5,376 KB
testcase_39 AC 127 ms
5,376 KB
testcase_40 AC 133 ms
5,376 KB
testcase_41 AC 133 ms
5,376 KB
testcase_42 AC 131 ms
5,376 KB
testcase_43 AC 134 ms
5,376 KB
testcase_44 AC 2 ms
5,376 KB
testcase_45 AC 2 ms
5,376 KB
testcase_46 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main(){
    ll n, a, b, c1, c2, ans = 1ll << 60;
    cin >> n >> a >> b;
    c1 = n / 2, c2 = n - c1;
    ans = min(ans, -a * (n - 1) + b * (c2 - c1));
    ans = min(ans, -a * (n - 1) + b * (c1 - c2));
    ans = min(ans, a * (n - 1) + b * (- n));
    for(ll i = 1; i * i <= 10000 * n; i++){
        c1 = n / i, c2 = n - c1;
        if(c2 < 0)break;
        ll d = min(2 * min(c1, c2), n - 1);
        ans = min(ans, a * (-d + (n - 1 - d)) + b * (c1 - c2));
        ans = min(ans, a * (-d + (n - 1 - d)) + b * (c2 - c1));
    }
    if(n <= 1000000){
        for(ll i = 0; i <= n; i++){
            ll d = min(2 * min(i, n - i), n - 1);
            ans = min(ans, a * (-d + (n - 1 - d)) + b * (i - (n - i)));
        }
    }
    cout << ans << endl;
}
0