Submission #81948

# Submission time Handle Problem Language Result Execution time Memory
81948 2018-10-28T08:33:22 Z Saboon Calvinball championship (CEOI15_teams) C++14
20 / 100
49 ms 16892 KB
#include <bits/stdc++.h>
#define F first
#define S second
#define PB push_back
#define PF push_front
#define MP make_pair
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
const int maxn = 1e3 + 10;
const int mod = 1e9 + 7;

ll dp[maxn][maxn], par[maxn], a[maxn];

int main() {
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		par[i] = max (par[i - 1], a[i]);
	}

	for (int i = 1; i <= n; i++)
		dp[0][i] = 1;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			dp[i][j] = (j * dp[i - 1][j] + dp[i - 1][j + 1]) % mod;
		}
	}
	ll ans = 0;
	for (int i = 1; i <= n; i++) {
		ans = (ans + (a[i] - 1) * dp[n - i][par[i - 1]] % mod);
	}
	cout << (ans + 1) % mod << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 512 KB Output is correct
3 Correct 2 ms 512 KB Output is correct
4 Correct 2 ms 556 KB Output is correct
5 Correct 2 ms 564 KB Output is correct
6 Correct 2 ms 596 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 600 KB Output is correct
2 Correct 2 ms 604 KB Output is correct
3 Correct 2 ms 736 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 736 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 1056 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 1060 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 4648 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 10 ms 8492 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 43 ms 16864 KB Execution killed with signal 11 (could be triggered by violating memory limits)
# Verdict Execution time Memory Grader output
1 Runtime error 31 ms 16864 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 49 ms 16892 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -