結果
問題 |
No.178 美しいWhitespace (1)
|
ユーザー |
|
提出日時 | 2015-12-06 14:46:25 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 547 bytes |
コンパイル時間 | 634 ms |
コンパイル使用メモリ | 64,984 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-09-14 15:19:45 |
合計ジャッジ時間 | 1,698 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge6 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 7 WA * 14 |
ソースコード
#include <iostream> #include <vector> #include <algorithm> using namespace std; int main(){ ios::sync_with_stdio(false); cin.tie(0); 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; }