Submission #43991

# Submission time Handle Problem Language Result Execution time Memory
43991 2018-03-29T08:55:52 Z sorry_Benq Calvinball championship (CEOI15_teams) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e6 + 7;

ll a[10005];
ll DP[10005];
ll mxs[10005];

/*int solve(int N, int K){
	//you have N numbers left, and they can start anywhere from 1 - K.
	if (DP[N][K] != 0) return DP[N][K];
	if (N == 0) return 1;
	else{
		return DP[N][K] = (((long long) K)*solve(N - 1, K) + solve(N - 1, K + 1))%MOD;
	}
}*/

int cnt = 10005; 
void evolve(){
	for (int i = 0; i < cnt - 1; i++){
		DP[i] = ((long long) i)*DP[i] + DP[i + 1];
		DP[i] %= MOD;
	}
	cnt--;
}



int main(){
	int N; cin >> N;
	for (int i = 0; i < N; i++){
		cin >> a[i];
	}
	for (int i = 0; i < cnt; i++){
		DP[i] = 1;
	}
	ll res = 1;
	int mx = 1;
	for (int i = 0; i < N; i++){
		mxs[i] = mx;
		mx = max(mx, a[i]);
	}
	for (int i = N - 1; i >= 0; i--){
		//matches prefix of length i
		res += ((ll) a[i] - 1)*DP[mxs[i]];
		evolve();
		res %= MOD;
	}
	cout << res << endl;
}

Compilation message

teams.cpp: In function 'int main()':
teams.cpp:42:20: error: no matching function for call to 'max(int&, ll&)'
   mx = max(mx, a[i]);
                    ^
In file included from /usr/include/c++/7/bits/specfun.h:45:0,
                 from /usr/include/c++/7/cmath:1914,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:41,
                 from teams.cpp:1:
/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:
teams.cpp:42:20: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll {aka long long int}')
   mx = max(mx, a[i]);
                    ^
In file included from /usr/include/c++/7/bits/specfun.h:45:0,
                 from /usr/include/c++/7/cmath:1914,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:41,
                 from teams.cpp:1:
/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:
teams.cpp:42:20: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll {aka long long int}')
   mx = max(mx, a[i]);
                    ^
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 teams.cpp:1:
/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:
teams.cpp:42:20: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   mx = max(mx, a[i]);
                    ^
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 teams.cpp:1:
/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:
teams.cpp:42:20: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   mx = max(mx, a[i]);
                    ^