結果
| 問題 | No.1389 Clumsy Calculation |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-02-12 22:09:19 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 34 ms / 2,000 ms |
| コード長 | 777 bytes |
| コンパイル時間 | 997 ms |
| コンパイル使用メモリ | 73,200 KB |
| 最終ジャッジ日時 | 2025-01-18 18:40:12 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 26 |
ソースコード
#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;
}