結果
問題 |
No.904 サメトロ
|
ユーザー |
![]() |
提出日時 | 2019-10-11 22:02:30 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,020 bytes |
コンパイル時間 | 1,503 ms |
コンパイル使用メモリ | 166,808 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-11-25 07:29:00 |
合計ジャッジ時間 | 2,476 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 WA * 16 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define int long long #define rep(i,n) for(int (i)=0;(i)<(n);(i)++) #define rrep(i,n) for(int (i)=((n)-1);(i)>=0;(i)--) #define itn int #define all(x) (x).begin(),(x).end() #define F first #define S second const long long INF = 1LL << 60; const int MOD = 1000000007; 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; } signed main(void){ int n; cin>>n; int in=0, out=0; rep(i,n-1){ int a,b; cin>>a>>b; in += a; out += b; } if(in == 0&& out == 0){ cout<<0<<endl; return 0; }else if(in == 0|| out == 0){ cout<<1<<endl; return 0; } if(in > out){ int sa = abs(in - out); cout<<in - sa + 1<<endl; }else if(in == out){ cout<<in + 1<<endl; }else{ int sa = abs(out - in); cout<<out - sa + 1<<endl; } }