답안 #124534

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
124534 2019-07-03T13:34:17 Z NMAC427 오벨리스크 (NOI14_obelisk) C++14
컴파일 오류
0 ms 0 KB
// https://oj.uz/problem/view/NOI14_orchard

#include <bits/stdc++.h>

#define int int64_t
#define coutV(x) for (const auto& e: x) {cerr << e << " ";} cerr << "\n"

using namespace std;

int N, M;
int totalApples = 0;

vector<vector<int>> orc;

inline int query(int i1, int j1, int i2, int j2) {
	return orc[i2][j2] + orc[i1][j1] - orc[i1][j2] - orc[i2][j1];
}

signed main() {
	
	#ifndef __APPLE__
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	#endif

	cin >> N >> M;

	orc = vector<vector<int>>(N + 1, vector<int>(M + 1, 0));

	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++) {
			int16_t v; 
			cin >> v;

			totalApples += v;

			orc[i + 1][j + 1] = 2 * v - 1;
			orc[i + 1][j + 1] += orc[i + 1][j] + orc[i][j + 1] - orc[i][j];
		}
	}


	#ifdef __APPLE__
	for (int i = 0; i <= N; i++) {
		for (int j = 0; j <= M; j++) {
			cerr << orc[i][j] << " ";
		} cerr << "\n";
	} cerr << "\n";
	#endif

	int maxSavings = 0;
	for (int i1 = 0; i1 < N; i1++) {
		for (int i2 = i1 + 1; i2 <= N; i2++) {
			// Maximum Subsetsum
			int currentSum = 0;

			for (int j = 0; j < M; j++) {
				currentSum += query(i1, j, i2, j + 1);;
				currentSum = max(currentSum, 0ll);
				maxSavings = max(maxSavings, currentSum);
			}
		}
	}

	// for (int i1 = 0; i1 < N; i1++) {
	// 	for (int j1 = 0; j1 < M; j1++) {
	// 		for (int i2 = i1 + 1; i2 <= N; i2++) {
	// 			for (int j2 = j1 + 1; j2 <= M; j2++) {
	// 				int q = query(i1, j1, i2, j2);
	// 				maxSavings = max(maxSavings, q);
	// 			}
	// 		}
	// 	}
	// }

	cout << totalApples - maxSavings << "\n";
}

Compilation message

obelisk.cpp: In function 'int main()':
obelisk.cpp:59:37: error: no matching function for call to 'max(int64_t&, long long int)'
     currentSum = max(currentSum, 0ll);
                                     ^
In file included from /usr/include/c++/7/bits/char_traits.h:39:0,
                 from /usr/include/c++/7/ios:40,
                 from /usr/include/c++/7/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from obelisk.cpp:3:
/usr/include/c++/7/bits/stl_algobase.h:219:5: note: candidate: template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)
     max(const _Tp& __a, const _Tp& __b)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:219:5: note:   template argument deduction/substitution failed:
obelisk.cpp:59:37: note:   deduced conflicting types for parameter 'const _Tp' ('long int' and 'long long int')
     currentSum = max(currentSum, 0ll);
                                     ^
In file included from /usr/include/c++/7/bits/char_traits.h:39:0,
                 from /usr/include/c++/7/ios:40,
                 from /usr/include/c++/7/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from obelisk.cpp:3:
/usr/include/c++/7/bits/stl_algobase.h:265:5: note: candidate: template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)
     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:265:5: note:   template argument deduction/substitution failed:
obelisk.cpp:59:37: note:   deduced conflicting types for parameter 'const _Tp' ('long int' and 'long long int')
     currentSum = max(currentSum, 0ll);
                                     ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from obelisk.cpp:3:
/usr/include/c++/7/bits/stl_algo.h:3462:5: note: candidate: template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)
     max(initializer_list<_Tp> __l)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3462:5: note:   template argument deduction/substitution failed:
obelisk.cpp:59:37: note:   mismatched types 'std::initializer_list<_Tp>' and 'long int'
     currentSum = max(currentSum, 0ll);
                                     ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from obelisk.cpp:3:
/usr/include/c++/7/bits/stl_algo.h:3468:5: note: candidate: template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)
     max(initializer_list<_Tp> __l, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
obelisk.cpp:59:37: note:   mismatched types 'std::initializer_list<_Tp>' and 'long int'
     currentSum = max(currentSum, 0ll);
                                     ^