結果

問題 No.1389 Clumsy Calculation
ユーザー outlineoutline
提出日時 2021-02-12 22:03:31
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 28 ms / 2,000 ms
コード長 1,431 bytes
コンパイル時間 1,772 ms
コンパイル使用メモリ 134,040 KB
実行使用メモリ 4,820 KB
最終ジャッジ日時 2023-09-27 04:03:26
合計ジャッジ時間 3,616 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 3 ms
4,380 KB
testcase_06 AC 2 ms
4,384 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 28 ms
4,536 KB
testcase_10 AC 14 ms
4,520 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,384 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 24 ms
4,820 KB
testcase_15 AC 25 ms
4,532 KB
testcase_16 AC 23 ms
4,676 KB
testcase_17 AC 26 ms
4,540 KB
testcase_18 AC 25 ms
4,564 KB
testcase_19 AC 26 ms
4,820 KB
testcase_20 AC 26 ms
4,692 KB
testcase_21 AC 25 ms
4,632 KB
testcase_22 AC 25 ms
4,524 KB
testcase_23 AC 25 ms
4,676 KB
testcase_24 AC 25 ms
4,580 KB
testcase_25 AC 26 ms
4,668 KB
testcase_26 AC 23 ms
4,568 KB
testcase_27 AC 23 ms
4,820 KB
testcase_28 AC 25 ms
4,560 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <array>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <fstream>
#include <complex>
#include <cstring>
#include <unordered_map>
#include <unordered_set>
using namespace std;

using ll = long long;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

template<class T>
inline bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

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

    int N, X;
    cin >> N >> X;
    vector<ll> S(N);
    ll sum = 0;
    for(int i = 0; i < N; ++i){
        cin >> S[i];
        sum += S[i];
    }
    
    for(int i = 0; i < N; ++i){
        if(S[i] % 2 == 1)   continue;
        sum -= S[i];
        sum += S[i] / 2;
        if(sum % (N - 1) == 0 && sum / (N - 1) == X){
            cout << S[i] / 2 << endl;
            return 0;
        }
        sum -= S[i] / 2;
        sum += S[i];
    }

    return 0;
}
0