답안 #55247

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
55247 2018-07-06T17:49:14 Z mraron Calvinball championship (CEOI15_teams) C++14
100 / 100
295 ms 1060 KB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
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;
}

Compilation message

teams.cpp:5:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main() {
      ^
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 504 KB Output is correct
2 Correct 2 ms 616 KB Output is correct
3 Correct 2 ms 620 KB Output is correct
4 Correct 3 ms 620 KB Output is correct
5 Correct 3 ms 620 KB Output is correct
6 Correct 2 ms 744 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 744 KB Output is correct
2 Correct 3 ms 792 KB Output is correct
3 Correct 2 ms 792 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 792 KB Output is correct
2 Correct 2 ms 792 KB Output is correct
3 Correct 2 ms 792 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 792 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 792 KB Output is correct
2 Correct 2 ms 792 KB Output is correct
3 Correct 2 ms 792 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 792 KB Output is correct
2 Correct 3 ms 792 KB Output is correct
3 Correct 3 ms 792 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 792 KB Output is correct
2 Correct 5 ms 792 KB Output is correct
3 Correct 5 ms 792 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 283 ms 928 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 56 ms 928 KB Output is correct
2 Correct 94 ms 928 KB Output is correct
3 Correct 79 ms 928 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 240 ms 936 KB Output is correct
2 Correct 295 ms 1020 KB Output is correct
3 Correct 271 ms 1060 KB Output is correct