Submission #126059

# Submission time Handle Problem Language Result Execution time Memory
126059 2019-07-06T21:54:19 Z Mahmoud_Adel Calvinball championship (CEOI15_teams) C++14
0 / 100
68 ms 65540 KB
#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
typedef long long ll;
const int N = 1e4+5, mod = 1e6+7;
ll n, dp[N][N][2], a[N];
ll sol(int i, ll j, int bit)
{
	if(i == n) return 1;
	ll &ret = dp[i][j][bit];
	if(ret != -1) return ret;
	if(bit) ret = j*sol(i+1, j, 1)%mod + sol(i+1, j+1, 1)%mod;
	else ret = (a[i]-1)*sol(i+1, max(j, a[i]-1), 1)%mod + 
	sol(i+1, max(j, a[i]), 0)%mod;
	return ret%mod;
}
int main()
{
	memset(dp, -1, sizeof dp);
	cin >> n;
	for(int i=0; i<n; i++) cin >> a[i];
	cout << sol(0, 0, 0) << endl;
}
# Verdict Execution time Memory Grader output
1 Runtime error 68 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 62 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 58 ms 65536 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 62 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
# Verdict Execution time Memory Grader output
1 Runtime error 61 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 61 ms 65536 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 64 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 61 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
# Verdict Execution time Memory Grader output
1 Runtime error 60 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 64 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -