結果

問題 No.178 美しいWhitespace (1)
ユーザー alpha_virginis
提出日時 2015-05-24 15:59:38
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 661 bytes
コンパイル時間 1,264 ms
コンパイル使用メモリ 160,348 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-07-06 06:47:34
合計ジャッジ時間 1,915 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

inline long nextInt(void) {
  long temp;
  std::cin >> temp;
  return temp;
}

int main() {

  long even = 0;
  long odd  = 0;
  long N;
  long max = -1;
  long ans = 0;
  long temp;
  std::vector<long> v;

  std::cin >> N;
  for(int i = 0; i < N; ++i) {
    temp = nextInt();
    temp += 4 * nextInt();
    v.push_back(temp);
    if( temp % 2 == 0 ) ++even;
    else ++odd;
    if( max < temp ) {
      max = temp;
    }
  }

  if( even != 0 && odd != 0 ) {
    std::cout << -1 << std::endl;
    return 0;
  }

  for(int i = 0; i < N; ++i) {
    ans += max - v[i];
  }

  ans /= 2;

  std::cout << ans << std::endl;
  
  return 0;
}

0