Submission #55245

# Submission time Handle Problem Language Result Execution time Memory
55245 2018-07-06T17:47:48 Z mraron Calvinball championship (CEOI15_teams) C++14
30 / 100
125 ms 716 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];
		}
	
		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 488 KB Output is correct
3 Correct 2 ms 572 KB Output is correct
4 Correct 2 ms 628 KB Output is correct
5 Correct 2 ms 628 KB Output is correct
6 Correct 2 ms 628 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 628 KB Output is correct
2 Correct 2 ms 700 KB Output is correct
3 Correct 2 ms 700 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 700 KB Output is correct
2 Correct 2 ms 700 KB Output is correct
3 Correct 2 ms 700 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 700 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 700 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 700 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 700 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 110 ms 716 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 27 ms 716 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 125 ms 716 KB Output isn't correct
2 Halted 0 ms 0 KB -