結果
問題 | No.178 美しいWhitespace (1) |
ユーザー |
![]() |
提出日時 | 2023-11-23 17:42:04 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 586 bytes |
コンパイル時間 | 1,838 ms |
コンパイル使用メモリ | 193,936 KB |
最終ジャッジ日時 | 2025-02-17 23:27:37 |
ジャッジサーバーID (参考情報) |
judge3 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 21 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); ++i) int main() { // Input int N; cin >> N; vector<int> w(N); rep(i, N) { int a, b; cin >> a >> b; w[i] = a + 4 * b; } // Trivial Exception rep(i, N-1) { if (w[i] % 2 != w[i+1] % 2) { cout << -1 << endl; return 0; } } // Calculation int maxw = *max_element(w.begin(), w.end()); long long ans = 0; rep(i, N) ans += (maxw - w[i]) / 2; // Output cout << ans << endl; }