Contest Duration: ~ (local time) (100 minutes) Back to Home

Submission #8587116

Source Code Expand

Copy
```#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
∧＿∧
∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
（ ´_ゝ`）　/　 ⌒i     @hamayanhamayan
／　　　＼　 　  |　|
/　　 /￣￣￣￣/　　|
＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/

int N; ll A[201010];
//---------------------------------------------------------------------------------------------------
void _main() {
cin >> N;
rep(i, 0, N) cin >> A[i];

ll tot = 0;
rep(i, 0, N) tot += A[i];

ll ans = infl;
ll lft = 0;
rep(i, 0, N) {
chmin(ans, abs(tot - lft - lft));
lft += A[i];
}
cout << ans << endl;
}

```

#### Submission Info

Submission Time 2019-11-23 22:41:41+0900 B - Iron Bar Cutting hamayanhamayan C++14 (GCC 5.4.1) 200 1644 Byte AC 23 ms 1792 KB

#### Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 sample_01.txt, sample_02.txt
All 200 / 200 in01.txt, in02.txt, in03.txt, in04.txt, in05.txt, in06.txt, in07.txt, in08.txt, in09.txt, in10.txt, in11.txt, in12.txt, in13.txt, in14.txt, in15.txt, in16.txt, in17.txt, in18.txt, sample_01.txt, sample_02.txt
Case Name Status Exec Time Memory
in01.txt 1 ms 256 KB
in02.txt 1 ms 256 KB
in03.txt 1 ms 256 KB
in04.txt 1 ms 256 KB
in05.txt 1 ms 256 KB
in06.txt 1 ms 256 KB
in07.txt 22 ms 1792 KB
in08.txt 22 ms 1792 KB
in09.txt 22 ms 1792 KB
in10.txt 22 ms 1792 KB
in11.txt 22 ms 1792 KB
in12.txt 22 ms 1792 KB
in13.txt 22 ms 1792 KB
in14.txt 22 ms 1792 KB
in15.txt 23 ms 1792 KB
in16.txt 22 ms 1792 KB
in17.txt 22 ms 1792 KB
in18.txt 1 ms 256 KB
sample_01.txt 1 ms 256 KB
sample_02.txt 1 ms 256 KB