結果
| 問題 |
No.178 美しいWhitespace (1)
|
| コンテスト | |
| ユーザー |
koyumeishi
|
| 提出日時 | 2015-04-05 23:25:19 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 2,000 ms |
| コード長 | 645 bytes |
| コンパイル時間 | 527 ms |
| コンパイル使用メモリ | 75,276 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-04 02:09:17 |
| 合計ジャッジ時間 | 1,311 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 21 |
ソースコード
#include <iostream>
#include <vector>
#include <cstdio>
#include <sstream>
#include <map>
#include <string>
#include <algorithm>
#include <queue>
#include <cmath>
#include <set>
using namespace std;
int main(){
int n;
cin >> n;
vector<int> a(n), b(n);
vector<int> l(n);
for(int i=0; i<n; i++){
cin >> a[i] >> b[i];
l[i] = a[i] + 4*b[i];
}
bool ok = true;
int max_ = l[0];
for(int i=1; i<n; i++){
if(l[i]%2 != l[i-1]%2) ok = false;
max_ = max(max_, l[i]);
}
if(ok == false){
cout << -1 << endl;
return 0;
}
long long ans = 0;
for(int i=0; i<n; i++){
ans += (max_ - l[i])/2;
}
cout << ans << endl;
return 0;
}
koyumeishi