Submission #211625

# Submission time Handle Problem Language Result Execution time Memory
211625 2020-03-20T20:48:56 Z MetB Calvinball championship (CEOI15_teams) C++14
0 / 100
278 ms 684 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace __gnu_pbds;
 
#define N 2000001
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
const ll INF = 1e18, MOD = 1e9 + 7, MOD2 = 1e6 + 3;

ll ans, d[10000][2], a[N], n, mx[N];

int main () {
	cin >> n;

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

	for (int i = 1; i <= n; i++) {
		d[i][0] = 1;
	}

	for (int i = n - 1; i > 0; i--) {
		int k = ((n - i) & 1);
		
		for (ll j = 1; j <= n; j++) {
			d[j][k] = (j * d[j][!k] + d[j+1][!k]) % MOD;
		}

		for (int j = a[i] - 1; j >= 1; j--) {
			ans += d[i ? mx[i-1] : 0LL][!k];
			if (ans >= MOD) ans -= MOD;
		}
	}

	ans = (ans + a[n-1] - 1) % MOD;

	cout << ans;
}
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 384 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 278 ms 684 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 58 ms 512 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 201 ms 640 KB Output isn't correct
2 Halted 0 ms 0 KB -