Submission #38184

#TimeUsernameProblemLanguageResultExecution timeMemory
38184farmersriceCalvinball championship (CEOI15_teams)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")
#pragma GCC target ("avx,tune=native")
//Use above if bruteforcing with lots of small operations. Or just use it anytime, there's no downside. AVX is better slightly
/*
TASK: hidden
LANG: C++11
*/
using namespace std;
typedef long long ll;
typedef pair<int, int> pair2;
typedef pair<int, pair<int, int> > pair3;
typedef pair<int, pair<int, pair<int, int> > > pair4;
#define MAXN 10013
#define INF 1000000000000000000LL
#define mp make_pair
#define add push_back
#define remove pop
#define MOD 1000007LL

ll n;
ll values[MAXN];
int num[MAXN];
ll dp[2][MAXN]; //dp[i][j]: num ways from point i IF the highest number that appears before us is j (implying value of i is at most j + 1)
//dp[i][j] = dp[i + 1][j] * j + dp[i + 1][j + 1]

int main() {
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL);

	cin >> n;

	for (int i = 0; i < n; i++) {
		cin >> values[i];
	}	

	for (int i = 0; i < 2; i++) {
		for (int j = 0; j < MAXN; j++) {
			dp[i][j] = 1;
		}
	}

	int answer = 0;
	int highestNum = 0;

	for (int i = 0; i < n; i++) {
		num[i] = highestNum;
		highestNum = max(highestNum, values[i]);
	}

	int old = 0;
	for (int i = n - 1; i >= 0; i--) {
		answer += ((values[i] - 1) * dp[old][num[i]]) % MOD;
		answer %= MOD;

		for (int j = 0; j < i; j++) {
			dp[1 - old][j] = dp[old][j] * j + dp[old][j + 1];
			dp[1 - old][j] %= MOD;
		}
		old = 1 - old;
	}

	cout << answer + 1 << endl;
}

Compilation message (stderr)

teams.cpp: In function 'int main()':
teams.cpp:49:41: error: no matching function for call to 'max(int&, ll&)'
   highestNum = max(highestNum, values[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/istream:38,
                 from /usr/include/c++/5/sstream:38,
                 from /usr/include/c++/5/complex:45,
                 from /usr/include/c++/5/ccomplex:38,
                 from /usr/include/x86_64-linux-gnu/c++/5/bits/stdc++.h:52,
                 from teams.cpp:1:
/usr/include/c++/5/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++/5/bits/stl_algobase.h:219:5: note:   template argument deduction/substitution failed:
teams.cpp:49:41: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll {aka long long int}')
   highestNum = max(highestNum, values[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/istream:38,
                 from /usr/include/c++/5/sstream:38,
                 from /usr/include/c++/5/complex:45,
                 from /usr/include/c++/5/ccomplex:38,
                 from /usr/include/x86_64-linux-gnu/c++/5/bits/stdc++.h:52,
                 from teams.cpp:1:
/usr/include/c++/5/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++/5/bits/stl_algobase.h:265:5: note:   template argument deduction/substitution failed:
teams.cpp:49:41: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll {aka long long int}')
   highestNum = max(highestNum, values[i]);
                                         ^
In file included from /usr/include/c++/5/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/5/bits/stdc++.h:64,
                 from teams.cpp:1:
/usr/include/c++/5/bits/stl_algo.h:3457:5: note: candidate: template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)
     max(initializer_list<_Tp> __l)
     ^
/usr/include/c++/5/bits/stl_algo.h:3457:5: note:   template argument deduction/substitution failed:
teams.cpp:49:41: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   highestNum = max(highestNum, values[i]);
                                         ^
In file included from /usr/include/c++/5/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/5/bits/stdc++.h:64,
                 from teams.cpp:1:
/usr/include/c++/5/bits/stl_algo.h:3463: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++/5/bits/stl_algo.h:3463:5: note:   template argument deduction/substitution failed:
teams.cpp:49:41: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   highestNum = max(highestNum, values[i]);
                                         ^