結果
問題 |
No.178 美しいWhitespace (1)
|
ユーザー |
![]() |
提出日時 | 2016-10-10 16:40:49 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 513 bytes |
コンパイル時間 | 1,306 ms |
コンパイル使用メモリ | 162,668 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-22 00:50:40 |
合計ジャッジ時間 | 2,146 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 21 |
ソースコード
#include<bits/stdc++.h> using namespace std; int main(){ int n; cin >> n; vector<int> space(n); int a, b; for(int i = 0; i < n; i++){ cin >> a >> b; space[i] = a + (4 * b); } sort(space.begin(), space.end()); reverse(space.begin(), space.end()); int max_space = space[0]; long long count = 0; for(int i = 1; i < n; i++){ int a = max_space - space[i]; if(a % 2 != 0){ count = -1; break; }else{ count += a / 2; } } cout << count << endl; }