結果

問題 No.1389 Clumsy Calculation
ユーザー MisterMister
提出日時 2021-02-12 22:09:19
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 30 ms / 2,000 ms
コード長 777 bytes
コンパイル時間 804 ms
コンパイル使用メモリ 74,020 KB
実行使用メモリ 6,312 KB
最終ジャッジ日時 2023-09-27 04:20:25
合計ジャッジ時間 2,936 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 3 ms
4,384 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 30 ms
6,124 KB
testcase_10 AC 16 ms
6,188 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,384 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 27 ms
6,188 KB
testcase_15 AC 26 ms
6,156 KB
testcase_16 AC 26 ms
6,268 KB
testcase_17 AC 28 ms
6,272 KB
testcase_18 AC 27 ms
6,272 KB
testcase_19 AC 28 ms
6,188 KB
testcase_20 AC 27 ms
6,188 KB
testcase_21 AC 28 ms
6,276 KB
testcase_22 AC 27 ms
6,312 KB
testcase_23 AC 28 ms
6,132 KB
testcase_24 AC 28 ms
6,260 KB
testcase_25 AC 28 ms
6,264 KB
testcase_26 AC 25 ms
6,188 KB
testcase_27 AC 26 ms
6,136 KB
testcase_28 AC 27 ms
6,264 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#line 1 "main.cpp"
#include <iostream>
#include <numeric>
#include <vector>

using namespace std;
using lint = long long;
constexpr lint INF = 1LL << 60;

void solve() {
    int n;
    lint sum;
    cin >> n >> sum;

    vector<lint> xs(n), ys(n);
    for (int i = 0; i < n; ++i) {
        lint s;
        cin >> s;

        xs[i] = sum - s;
        if (s % 2 == 0) {
            ys[i] = sum - s / 2;
        } else {
            ys[i] = INF;
        }
    }

    lint nsum = accumulate(xs.begin(), xs.end(), 0LL);
    for (int i = 0; i < n; ++i) {
        if (nsum - xs[i] + ys[i] == sum) {
            cout << (sum - xs[i]) / 2 << "\n";
            return;
        }
    }
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    solve();

    return 0;
}
0