Submission #8573784


Source Code Expand

Copy
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>
#include <cmath>

auto& in = std::cin;
auto& out = std::cout;
#define all_range(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;

int32_t N;
int64_t sum[210000];

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	in.tie(nullptr);
	out.tie(nullptr);

	in >> N;
	for (size_t i = 0; i < N; i++)
	{
		in >> sum[i];
	}
	for (size_t i = 1; i <= N; i++)
	{
		sum[i] += sum[i-1];
	}

	auto res = sum[N];
	for (size_t i = 0; i < N; i++)
	{
		res = std::min(res, std::abs((sum[N] - sum[i]) - sum[i]));
	}
	out << res << endl;


	return 0;
}
#endif

Submission Info

Submission Time
Task B - Iron Bar Cutting
User eiya
Language C++14 (GCC 5.4.1)
Score 200
Code Size 1105 Byte
Status AC
Exec Time 23 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 23 ms 1792 KB
in08.txt AC 23 ms 1792 KB
in09.txt AC 23 ms 1792 KB
in10.txt AC 23 ms 1792 KB
in11.txt AC 23 ms 1792 KB
in12.txt AC 23 ms 1792 KB
in13.txt AC 23 ms 1792 KB
in14.txt AC 23 ms 1792 KB
in15.txt AC 23 ms 1792 KB
in16.txt AC 23 ms 1792 KB
in17.txt AC 22 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