結果
問題 |
No.904 サメトロ
|
ユーザー |
![]() |
提出日時 | 2019-10-12 02:27:06 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 1,000 ms |
コード長 | 609 bytes |
コンパイル時間 | 1,791 ms |
コンパイル使用メモリ | 178,224 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-26 07:40:37 |
合計ジャッジ時間 | 2,702 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 33 |
ソースコード
#pragma GCC optimize("Ofast") #include <bits/stdc++.h> using namespace std; #define REP(i,n) for(int i = 0; i < (int)(n); ++i) #define ALL(a) (a).begin(),(a).end() typedef long long ll; int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int N; cin >> N; vector<int> A(N+1,0), B(N+1,0); REP(i,N-1){ cin >> A[i] >> B[i]; } int s = accumulate(ALL(A), 0); int t = accumulate(ALL(B), 0); int ma = 0, mb = 0; REP(i,N-1){ ma = max(ma, A[i]+B[i]-s); mb = max(mb, A[i]+B[i]-t); } cout << min(t-ma,s-mb) + 1 << endl; return 0; }