結果
| 問題 |
No.178 美しいWhitespace (1)
|
| コンテスト | |
| ユーザー |
ikd
|
| 提出日時 | 2015-11-02 12:00:11 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 683 bytes |
| コンパイル時間 | 588 ms |
| コンパイル使用メモリ | 67,076 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-09-13 07:01:05 |
| 合計ジャッジ時間 | 1,366 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 21 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:15:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
15 | scanf("%d %d", &a[i], &b[i]);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
int n;
cin>> n;
vector<int> a(n), b(n);
vector<long long int> wide(n);
for(int i=0; i<n; i++){
scanf("%d %d", &a[i], &b[i]);
wide[i] = a[i]+4*b[i];
}
sort(wide.begin(), wide.end());
bool flag = true;
for(int i=1; i<n; i++){
if(wide[i-1]%2!=wide[i]%2){
flag = false;
}
}
int long long cnt = 0;
if(flag){
for(int i=0; i<n-1; i++){
cnt += (wide[n-1]-wide[i])/2;
}
cout<< cnt<< endl;
}else{
cout<< "-1"<< endl;
}
return 0;
}
ikd