結果

問題 No.178 美しいWhitespace (1)
コンテスト
ユーザー msm1993
提出日時 2020-10-23 16:11:58
言語 C++14
(gcc 15.3.0 + boost 1.92.0)
コンパイル:
g++-15 -O2 -lm -std=c++14 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 1 ms / 2,000 ms
+ 757µs
コード長 825 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 521 ms
コンパイル使用メモリ 111,168 KB
実行使用メモリ 5,888 KB
最終ジャッジ日時 2026-08-21 14:14:56
合計ジャッジ時間 2,715 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <string>
#include <map>
#include <iterator>
#include <set>
#include <queue>
#include <bitset>
#include <cassert>

using namespace std;

int main() {

    int N;
    cin >> N;
    int a, b;
    cin >> a >> b;
    vector<int> vs;
    int m = a + 4 * b;
    vs.push_back(a + 4 * b);
    for (int i = 1; i < N; ++i) {
        cin >> a >> b;
        m = max(m, a + 4 * b);
        vs.push_back(a + 4 * b);
    }

    for (int i = 0; i < N; ++i) {
        if ((m % 2) != (vs[i] % 2)) {
            cout << -1 << endl;
            return 0;
        }
    }
    long ans = 0;
    for (int i = 0; i < N; ++i) {
        ans += (m - vs[i]) / 2;
    }
    cout << ans << endl;


    return 0;

}
0