Submission #63641

# Submission time Handle Problem Language Result Execution time Memory
63641 2018-08-02T10:24:21 Z khohko Calvinball championship (CEOI15_teams) C++17
20 / 100
1000 ms 1380 KB
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define fr first
#define sc second
#define ARRS ((ll)(2e6+500))
#define MAX ((ll)(1e9+100))
#define MOD ((ll)1e9+7)
#define mi(a,b) a=min((a),(b))

ll n,m,k,p,l,r,q;
ll a[ARRS];

ll slv(ll i,ll c,ll e=0){
	if(i==n)return 1;
	if(e)
		return c*slv(i+1,c,e)+slv(i+1,c+1,e);
	else {
		ll pas=0;
		if(a[i]==c+1){
			pas+=c*slv(i+1,c,1);
			pas+=slv(i+1,c+1,0);
		}
		else {
			pas+=(a[i]-1)*slv(i+1,c,1);
			pas+=slv(i+1,c,0);
		}
		pas%=MOD;
		return pas;
	}
}

int main(){
	#ifdef KHOKHO
			freopen("in.in","r",stdin);
			freopen("out.out","w",stdout);
	#endif
	cin>>n;
	for(int i=0; i<n; i++)cin>>a[i];
	cout<<slv(0,0,0);
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 436 KB Output is correct
4 Correct 2 ms 492 KB Output is correct
5 Correct 2 ms 504 KB Output is correct
6 Correct 2 ms 564 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 640 KB Output is correct
2 Correct 3 ms 644 KB Output is correct
3 Correct 3 ms 648 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 648 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1077 ms 648 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Execution timed out 1057 ms 672 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1066 ms 672 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1043 ms 672 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1074 ms 1316 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Execution timed out 1075 ms 1316 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1077 ms 1380 KB Time limit exceeded
2 Halted 0 ms 0 KB -