Submission #8573573


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, 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 0
Code Size 1100 Byte
Status CE

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:55:54: error: no matching function for call to ‘min(long int&, int)’
   res = std::min(res, abs((sum[N] - sum[i]) - sum[i]));
                                                      ^
In file included from /usr/include/c++/5/bits/char_traits.h:39:0,
                 from /usr/include/c++/5/ios:40,
                 from /usr/include/c++/5/ostream:38,
                 from /usr/include/c++/5/iostream:39,
                 from ./Main.cpp:3:
/usr/include/c++/5/bits/stl_algobase.h:195:5: note: candidate: template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)
     min(const _Tp& __a, const _Tp& __b)
     ^
/usr/include/c++/5/bits/stl_algobase.h:195:5: note:   template argument deduction/substitution failed:
./Main.cpp:55:54: note:   deduced conflicting types for parameter ‘const _Tp’ (‘long int’ and ‘int’)
   res = std::min(res, abs((sum[N] - sum[i]) - sum[i]));
                                                      ^
In file included from /usr/incl...