結果

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

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long int n, a, b, max, total=0, parity;
  vector<int> w;

  cin >> n;
  for(int i=0; i<n; ++i){
    cin >> a >> b;
    w.push_back(a+b*4);
  }
  sort(w.begin(), w.end());
  max = w.back();
  parity = max%2;
  for(int i=0; i<n-1; ++i){
    if(w[i]%2!=parity){
      cout << -1 << "\n";
      return 0;
    }else{
      while(w[i]<max){
	++total;
	w[i]+=2;
      }
    }
  }
  cout << total << "\n";

  return 0;
}
0