Submission #223876

# Submission time Handle Problem Language Result Execution time Memory
223876 2020-04-16T19:27:13 Z kshitij_sodani Calvinball championship (CEOI15_teams) C++17
10 / 100
774 ms 632 KB
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define a first
#define b second
#define pb push_back
int mod=1000007;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin>>n;
	int it[n];
	for(int i=0;i<n;i++){
		cin>>it[i];
	}
	int pre[n];
	pre[0]=it[0];
	for(int i=1;i<n;i++){
		pre[i]=max(pre[i-1],it[i]);
	}
	int dp[n];
	for(int i=0;i<n;i++){
		dp[i]=1;
	}
	int tot=0;
	for(int i=n-1;i>=0;i--){
		int dp2[n];
		if(it[i]<pre[i]){
			tot+=(dp[pre[i]-1]*(pre[i]-it[i]));
		}
		if(i>0){
			if(it[i]!=pre[i-1]+1){
				tot+=dp[pre[i]];
			}
		}	
		tot%=mod;
		for(int j=0;j<n;j++){
			if(i==n-1){
				dp2[j]=1;
			}
			else{
				dp2[j]=(dp[j]*(j+1));
				if(j<n-1){
					dp2[j]+=dp[j+1];
				}
				dp2[j]%=mod;
			}
		}
		for(int j=0;j<n;j++){
			dp[j]=dp2[j];
		}
	/*	cout<<tot<<endl;
		for(int j=0;j<n;j++){
			cout<<dp[j]<<" ";
		}
		cout<<endl;*/
		if(i==0){
			tot=(dp[0]-tot+mod)%mod;
		}
	}
	cout<<tot<<endl;
	return 0;
}
# 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 Correct 5 ms 384 KB Output is correct
# 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 6 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 12 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 753 ms 580 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 193 ms 632 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 774 ms 572 KB Output isn't correct
2 Halted 0 ms 0 KB -