Submission #55246

# Submission time Handle Problem Language Result Execution time Memory
55246 2018-07-06T17:48:40 Z mraron Calvinball championship (CEOI15_teams) C++14
70 / 100
403 ms 776 KB
#include<bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin>>n;
    vector<int> t(n);
    for(int i=0;i<n;++i) {
		cin>>t[i];
    }
	vector<int> mx(n);
	mx[0]=1;
	vector<bool> fontos(n);
	for(int i=1;i<n;++i) {
		mx[i]=max(t[i], mx[i-1]);
		fontos[i]=(mx[i]>mx[i-1]);
	}
	
	vector<int> dp[2];
	dp[0]=vector<int>(10021);
	dp[1]=vector<int>(10021);
	
	for(int i=0;i<=n;++i) {
		dp[(n-1)&1][i]=1;
	}
	
	int ans=t[n-1]-1;
	int mod=1e6+7;
	for(int i=n-2;i>=0;i--) {
		for(int j=0;j<=n;++j) {
			dp[i&1][j]=(dp[(i&1)^1][j]*j+dp[(i&1)^1][j+1])%mod;
		}
	
		if(fontos[i]) {
			ans=(ans+(t[i]-1)*dp[i&1][mx[i]-1])%mod;
		}else {
			ans=(ans+(t[i]-1)*dp[i&1][mx[i]])%mod;
		}
		
		
		//cerr<<mx[i]<<" "<<dp[i&1][mx[i]]<<"\n";
		//ans=(ans+dp[i&1][mx[i]])%mod;
	}
	
	cout<<ans+1<<"\n";
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 484 KB Output is correct
3 Correct 3 ms 484 KB Output is correct
4 Correct 3 ms 484 KB Output is correct
5 Correct 3 ms 596 KB Output is correct
6 Correct 2 ms 596 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 596 KB Output is correct
2 Correct 2 ms 672 KB Output is correct
3 Correct 2 ms 672 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 672 KB Output is correct
2 Correct 2 ms 696 KB Output is correct
3 Correct 2 ms 696 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 696 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 696 KB Output is correct
2 Correct 2 ms 696 KB Output is correct
3 Correct 2 ms 696 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 696 KB Output is correct
2 Correct 4 ms 696 KB Output is correct
3 Correct 4 ms 696 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 696 KB Output is correct
2 Correct 7 ms 696 KB Output is correct
3 Correct 5 ms 696 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 265 ms 776 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 77 ms 776 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 403 ms 776 KB Output isn't correct
2 Halted 0 ms 0 KB -