Submission #8573076


Source Code Expand

Copy
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

ll a[225816];

int main(void){
	int n,i;
	ll t=0ll,l,ans=INFLL;
	cin >> n;
	for(i=0; i<n; ++i){
		cin >> a[i];
		t += a[i];
	}
	l = a[0];
	for(i=1; i<n; ++i){
		ans = min(ans,abs(t-l-l));
		l += a[i];
	}
	cout << ans << endl;
	return 0;
}

Submission Info

Submission Time
Task B - Iron Bar Cutting
User ransewhale
Language C++14 (GCC 5.4.1)
Score 200
Code Size 611 Byte
Status AC
Exec Time 86 ms
Memory 1792 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 200 / 200
Status
AC × 2
AC × 20
Set Name Test Cases
Sample sample_01.txt, sample_02.txt
All 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 AC 1 ms 256 KB
in02.txt AC 1 ms 256 KB
in03.txt AC 1 ms 256 KB
in04.txt AC 1 ms 256 KB
in05.txt AC 1 ms 256 KB
in06.txt AC 1 ms 256 KB
in07.txt AC 82 ms 1792 KB
in08.txt AC 83 ms 1792 KB
in09.txt AC 82 ms 1792 KB
in10.txt AC 82 ms 1792 KB
in11.txt AC 85 ms 1792 KB
in12.txt AC 83 ms 1792 KB
in13.txt AC 82 ms 1792 KB
in14.txt AC 82 ms 1792 KB
in15.txt AC 82 ms 1792 KB
in16.txt AC 82 ms 1792 KB
in17.txt AC 86 ms 1792 KB
in18.txt AC 1 ms 256 KB
sample_01.txt AC 1 ms 256 KB
sample_02.txt AC 1 ms 256 KB