結果
| 問題 |
No.904 サメトロ
|
| コンテスト | |
| ユーザー |
risujiroh
|
| 提出日時 | 2019-10-11 22:02:59 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 32 ms / 1,000 ms |
| コード長 | 873 bytes |
| コンパイル時間 | 1,348 ms |
| コンパイル使用メモリ | 168,960 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-11-25 07:30:28 |
| 合計ジャッジ時間 | 2,267 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 33 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
int main() {
cin.tie(nullptr); ios::sync_with_stdio(false);
int n; cin >> n;
V<> a(n), b(n);
for (int i = 1; i < n; ++i) {
cin >> a[i] >> b[i];
}
int sa = accumulate(begin(a), end(a), 0);
int sb = accumulate(begin(b), end(b), 0);
int res = 0;
for (a[0] = 0; a[0] <= sb; ++a[0]) {
b[0] = a[0] + sa - sb;
if (b[0] < 0 or b[0] > sa) continue;
int ta = accumulate(begin(a), end(a), 0);
int tb = accumulate(begin(b), end(b), 0);
bool ok = true;
for (int i = 0; i < n; ++i) {
if (a[i] > tb - b[i]) {
ok = false;
break;
}
if (b[i] > ta - a[i]) {
ok = false;
break;
}
}
res += ok;
}
cout << res << '\n';
}
risujiroh