結果
問題 | No.178 美しいWhitespace (1) |
ユーザー |
|
提出日時 | 2017-11-21 17:48:18 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 493 bytes |
コンパイル時間 | 2,088 ms |
コンパイル使用メモリ | 161,608 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-26 08:17:12 |
合計ジャッジ時間 | 2,187 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 21 |
ソースコード
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main(void) { int n; cin >> n; ll maxs = 0; vector<ll> a(n), b(n); for (int i = 0; i < n; i++) { cin >> a[i] >> b[i]; if (a[i] + 4 * b[i] <= maxs) continue; maxs = a[i] + 4 * b[i]; } ll ans = 0; for (int i = 0; i < n; i++) { if (ans < 0) continue; ll diff = maxs - a[i] - 4 * b[i]; if (diff % 2 == 0) ans += diff / 2; else ans = -1; } cout << ans << endl; return 0; }