結果

問題 No.1389 Clumsy Calculation
ユーザー Example0911
提出日時 2021-02-12 21:26:00
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 26 ms / 2,000 ms
コード長 573 bytes
コンパイル時間 1,783 ms
コンパイル使用メモリ 196,064 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2025-01-29 12:42:59
合計ジャッジ時間 4,180 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 26
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;

using ll = long long;
using P = pair<ll, ll>;
const ll INF = (1LL << 61);
ll mod = (ll)1e9 + 7;

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll N, X; cin >> N >> X;
	vector<ll>S(N); for (int i = 0; i < N; i++)cin >> S[i];
	vector<ll>a(N);
	for (int i = 0; i < N; i++) {
		a[i] = X - S[i];
	}
	ll sum = 0;
	for (int i = 0; i < N; i++) {
		sum += a[i];
	}
	for (int i = 0; i < N; i++) {
		sum -= a[i];
		if (sum + (X - (S[i] / 2)) == X) {
			cout << S[i] / 2 << endl; return 0;
		}
		sum += a[i];
	}
	return 0;
}
0