結果
| 問題 |
No.178 美しいWhitespace (1)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-01-20 21:36:47 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 729 bytes |
| コンパイル時間 | 939 ms |
| コンパイル使用メモリ | 104,332 KB |
| 最終ジャッジ日時 | 2025-01-18 02:57:25 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 21 |
ソースコード
#include <algorithm>
#include <array>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <numeric>
#include <optional>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
int main() {
int32_t n;
cin >> n;
vector<int64_t> sums(n);
int64_t r = 0;
for (auto i = 0; i < n; ++i) {
int64_t a, b;
cin >> a >> b;
auto s = a + 4 * b;
sums[i] = s;
r += s % 2;
}
if (!(r == 0 || r == n)) {
cout << -1 << endl;
return 0;
}
int64_t mx = *max_element(sums.begin(), sums.end());
int64_t ans = 0;
for (auto s : sums) {
ans += mx - s;
}
cout << ans / 2 << endl;
return 0;
}