結果

問題 No.178 美しいWhitespace (1)
ユーザー ldsyb
提出日時 2016-02-27 15:37:35
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 497 bytes
コンパイル時間 508 ms
コンパイル使用メモリ 59,312 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-09-24 11:39:18
合計ジャッジ時間 1,364 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 7 WA * 14
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cmath>
using namespace std;

int main(){
   int ans = 0,lenmax = 0,n;
   bool oe;
   cin >> n;
   int a[n],b[n],length[n];
   for(int i = 0;i < n;i++){
      cin >> a[i] >> b[i];
      length[i] = a[i] + 4 * b[i];
      if(!i) oe = length[i] % 2;
      else if(oe != length[i] % 2){
         cout << -1 << endl;
         return 0;
      }
      lenmax = max(lenmax,length[i]);
   }
   for(int i = 0;i < n;i++) ans += lenmax - length[i];
   cout << ans / 2 << endl;
}
0