Submission #81968

# Submission time Handle Problem Language Result Execution time Memory
81968 2018-10-28T09:18:12 Z Saboon Calvinball championship (CEOI15_teams) C++14
70 / 100
42 ms 16800 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 = 1e6 + 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] = (1ll * j * dp[i - 1][j] + dp[i - 1][j + 1]) % mod;
		}
	}
	ll ans = 0;
	for (int i = 1; i <= n; i++) {
		ans = (ans + 1ll * (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 464 KB Output is correct
3 Correct 2 ms 464 KB Output is correct
4 Correct 2 ms 500 KB Output is correct
5 Correct 2 ms 516 KB Output is correct
6 Correct 2 ms 564 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 596 KB Output is correct
2 Correct 2 ms 596 KB Output is correct
3 Correct 2 ms 608 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 608 KB Output is correct
2 Correct 2 ms 608 KB Output is correct
3 Correct 2 ms 612 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1000 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1000 KB Output is correct
2 Correct 2 ms 1000 KB Output is correct
3 Correct 2 ms 1040 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 4664 KB Output is correct
2 Correct 5 ms 4664 KB Output is correct
3 Correct 5 ms 4664 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 8440 KB Output is correct
2 Correct 10 ms 8440 KB Output is correct
3 Correct 10 ms 8448 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 42 ms 16640 KB Execution killed with signal 11 (could be triggered by violating memory limits)
# Verdict Execution time Memory Grader output
1 Runtime error 31 ms 16800 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 42 ms 16800 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -