結果
| 問題 |
No.999 てん vs. ほむ
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-04-09 01:02:28 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 768 bytes |
| コンパイル時間 | 1,518 ms |
| コンパイル使用メモリ | 168,724 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-19 05:57:45 |
| 合計ジャッジ時間 | 3,594 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 6 WA * 14 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()
template <class T> inline bool chmin(T &a, T b) {if (a > b){a = b;return true;}return false;}
template <class T> inline bool chmax(T &a, T b) {if (a < b){a = b;return true;}return false;}
int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int n;cin>>n;
vector<P> a(n);
int sum=0;
rep(i, n){
int p,q;cin>>p>>q;
a[i] = make_pair(p,q);
sum+=(p-q);
}
int ans = sum;
for(int i=n-1;i>=0;i--){
P p = a[i];
sum = sum-(p.first-p.second)+(p.second-p.first);
ans = max(ans, sum);
}
cout<<ans<<endl;
}