結果
問題 |
No.904 サメトロ
|
ユーザー |
|
提出日時 | 2022-10-06 00:36:46 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 15 ms / 1,000 ms |
コード長 | 659 bytes |
コンパイル時間 | 2,041 ms |
コンパイル使用メモリ | 195,460 KB |
最終ジャッジ日時 | 2025-02-07 22:08:31 |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 33 |
ソースコード
#include <bits/stdc++.h> #define rep(i,n) for(int i = 0; i < (n); i++) using namespace std; typedef long long ll; int main(){ cin.tie(0); ios::sync_with_stdio(0); // Ai <= sum(B) - Bi // A1 + sum(A) == B1 + sum(B) int N; cin >> N; N--; vector<int> A(N), B(N); rep(i,N) cin >> A[i] >> B[i]; int sumA = accumulate(A.begin(), A.end(), 0); int sumB = accumulate(B.begin(), B.end(), 0); int ans = 0; for(int A1 = 0; A1 <= sumB; A1++) { int B1 = A1 + sumA - sumB; int ok = 1; ok &= B1 >= 0; rep(i,N) ok &= A[i] <= sumB + B1 - B[i]; ans += ok; } cout << ans << endl; }