結果
問題 |
No.999 てん vs. ほむ
|
ユーザー |
|
提出日時 | 2020-02-28 21:28:58 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 523 bytes |
コンパイル時間 | 805 ms |
コンパイル使用メモリ | 79,356 KB |
最終ジャッジ日時 | 2025-01-09 02:34:45 |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 18 WA * 2 |
ソースコード
#include <iostream> #include <vector> #include <map> #include <algorithm> using namespace std; typedef long long int ll; int main(){ cin.tie(nullptr); ios::sync_with_stdio(false); int n; cin >> n; vector<ll> a(2*n); for(int i=0;i<2*n;i++){ cin >> a[i]; } vector<ll> cnt(n+1,0),cnt2(n+1,0); for(int i=0;i<n;i++){ cnt[i+1]=a[i*2]-a[i*2+1]+cnt[i]; } for(int i=n-1;i>0;i--){ cnt2[i]=cnt2[i+1]+a[i*2+1]-a[i*2]; } ll ans=cnt[n]; for(int i=0;i<n;i++){ ans=max(ans,cnt[i]+cnt2[i]); } cout << ans << endl; }