結果

問題 No.178 美しいWhitespace (1)
ユーザー tnakao0123tnakao0123
提出日時 2016-03-25 10:47:15
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 980 bytes
コンパイル時間 648 ms
コンパイル使用メモリ 84,668 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-09 23:49:01
合計ジャッジ時間 1,627 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 1 ms
6,940 KB
testcase_03 AC 1 ms
6,940 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 3 ms
6,944 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 3 ms
6,940 KB
testcase_12 AC 3 ms
6,940 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 3 ms
6,940 KB
testcase_19 WA -
testcase_20 AC 2 ms
6,940 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 2 ms
6,944 KB
testcase_24 AC 3 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

/* -*- coding: utf-8 -*-
 *
 * 178.cc: No.178 美しいWhitespace (1) - yukicoder
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 1000;

/* typedef */

/* global variables */

int abis[MAX_N];

/* subroutines */

/* main */

int main() {
  int n;
  cin >> n;

  int maxab = 0;
  for (int i = 0; i < n; i++) {
    int a, b;
    cin >> a >> b;
    abis[i] = a + 4 * b;
    if (maxab < abis[i]) maxab = abis[i];
  }

  int p = (abis[0] & 1);
  for (int i = 1; i < n; i++)
    if ((abis[i] & 1) != p) {
      puts("-1");
      return 0;
    }

  int sum = 0;
  for (int i = 0; i < n; i++)
    sum += (maxab - abis[i]) / 2;

  printf("%d\n", sum);
  return 0;
}
0