Submission #366021

# Submission time Handle Problem Language Result Execution time Memory
366021 2021-02-12T18:19:32 Z kostia244 Calvinball championship (CEOI15_teams) C++17
100 / 100
205 ms 620 KB
#include<bits/stdc++.h>
#define all(x) begin(x), end(x)
using namespace std;
using ll = long long;
const int maxn = 1e4+1, mod = 1e6 + 7;
using state = array<int, maxn>;
int n;
state def;
void add(int &a, int b) { a = a+b>=mod?a+b-mod:a+b; }
int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin >> n;
	def.fill(0);
	state dp = def;
	int lk = 0;
	for(int A, i = 1; i <= n; i++) {
		cin >> A;
		auto ndp = def;
		add(ndp[lk], A-1);
		lk = max(lk, A);
		for(int k = 0; k < i; k++) {
			ndp[k] = (ndp[k] + dp[k]*1ll*k)%mod;
			add(ndp[k+1], dp[k]);
		}
		dp = ndp;
		//for(int i = 0; i <= n; i++) cout << dp[i] << " "; cout << endl;
	}
	int sm = 1;
	for(int i = 0; i <= n; i++) add(sm, dp[i]);
	cout << sm << '\n';
}
	
# Verdict Execution time Memory Grader output
1 Correct 1 ms 492 KB Output is correct
2 Correct 1 ms 492 KB Output is correct
3 Correct 1 ms 492 KB Output is correct
4 Correct 1 ms 492 KB Output is correct
5 Correct 1 ms 492 KB Output is correct
6 Correct 1 ms 492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 492 KB Output is correct
2 Correct 1 ms 492 KB Output is correct
3 Correct 1 ms 492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 492 KB Output is correct
2 Correct 1 ms 492 KB Output is correct
3 Correct 1 ms 492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 492 KB Output is correct
2 Correct 1 ms 492 KB Output is correct
3 Correct 1 ms 492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 492 KB Output is correct
2 Correct 3 ms 492 KB Output is correct
3 Correct 4 ms 492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 492 KB Output is correct
2 Correct 6 ms 492 KB Output is correct
3 Correct 6 ms 404 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 201 ms 492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 60 ms 508 KB Output is correct
2 Correct 61 ms 524 KB Output is correct
3 Correct 61 ms 492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 205 ms 620 KB Output is correct
2 Correct 205 ms 492 KB Output is correct
3 Correct 204 ms 492 KB Output is correct