結果
問題 | No.999 てん vs. ほむ |
ユーザー |
![]() |
提出日時 | 2020-02-28 22:15:51 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,575 bytes |
コンパイル時間 | 985 ms |
コンパイル使用メモリ | 108,480 KB |
最終ジャッジ日時 | 2025-01-09 02:47:29 |
ジャッジサーバーID (参考情報) |
judge3 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 15 WA * 5 |
ソースコード
// https://atcoder.jp/contests/abcXXX/tasks/abcXXX_x #include <iostream> #include <vector> #include <tuple> #include <algorithm> #include <string> #include <cmath> #include <map> #include <set> #include <unordered_map> #include <unordered_set> #include <queue> #include <cassert> using namespace std; using ll = long long; using ull = unsigned long long; using pll = pair<ll, ll>; static const ll INF = 1001001001; static const ll LLINF = 1001001001001001001; #define REP(i, n) for(ll i = 0; i < (n); ++i) #define RANGE(i, m, n) for(ll i = (m); i <= (n); ++i) #define RRANGE(i, m, n) for(ll i = (m); i >= (n); --i) #define POSITIVE(x) (x)=((x) < 0) ? 0 : (x) ll power(ll x, ll y) { ll ret = 1; while(y-- > 0) ret *= x; return ret; } ll gcd(ll a, ll b) { assert(a >= 0); assert(b >= 0); if (b == 0) return a; return gcd(b, a % b); } ll iabs(ll x) { return x < 0 ? -x : x; } ll extgcd(ll a, ll b, ll& x, ll& y) { x = 1; y = 0; assert(a >= 0); assert(b >= 0); if (b == 0) return a; ll X, Y; auto d = extgcd(b, a % b, X, Y); x = Y; y = X - (a / b) * Y; return d; } int run(istream& in, ostream& out) { ll N; in >> N; vector<ll> v(2*N); ll a=0, b = 0; REP(i, N) { in >> v[2*i]; in >> v[2*i+1]; a+= v[2*i]; b+= v[2*i+1]; } ll total = a - b; ll ans = total; REP(i, N) { total -= 2*(v[2*i] - v[2*i+1]); ans = max(ans, iabs(total)); } out << ans << endl; return 0; } int main() { return run(cin, cout); }