結果
| 問題 |
No.904 サメトロ
|
| コンテスト | |
| ユーザー |
hipopo
|
| 提出日時 | 2020-01-12 18:05:51 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 29 ms / 1,000 ms |
| コード長 | 639 bytes |
| コンパイル時間 | 2,212 ms |
| コンパイル使用メモリ | 193,944 KB |
| 最終ジャッジ日時 | 2025-01-08 17:13:22 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 33 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
int n;
cin >> n;
vector<int> a(n - 1), b(n - 1);
int sum_a = 0, sum_b = 0;
for (int i = 0; i < n - 1; i++) {
cin >> a.at(i) >> b.at(i);
sum_a += a.at(i);
sum_b += b.at(i);
}
int cnt = 0;
int d = sum_a - sum_b;
for (int a0 = 0; a0 <= sum_b; a0++) {
int b0 = a0 + d;
if (b0 < 0) continue;
bool ok = true;
for (int i = 0; i < n - 1; i++) {
if (sum_b - b.at(i) + b0 < a.at(i)) ok = false;
}
if (ok) cnt++;
}
cout << cnt << endl;
}
hipopo