답안 #34389

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
34389 2017-11-10T20:47:47 Z bnahmad15 Calvinball championship (CEOI15_teams) C++14
70 / 100
446 ms 2172 KB
#include <bits/stdc++.h>
using namespace std;

const int N = 10010,MOD = 1000007;
int n,ar[N],dp[2][N],mx[N],ans = 0;

int main() {
	
	scanf("%d",&n);
	mx[0]=0;
	for(int i =0 ;i<n;i++){
		scanf("%d",&ar[i]);
		if (i){
			mx[i]=max(mx[i-1],ar[i-1]);
		}
	}
	for (int i = 0 ;i <= n+5 ; i++)
		dp[n&1][i]=1;
	for (int i = n-1;i >= 0 ;i--){
		int m = mx[i];
		for (int j =1 ;j < ar[i];j++){
			m = max(m,j);
			ans += dp[(i+1) & 1][m];
			ans %= MOD;
		}
		for (int j = 1; j<=i+1;j++){
			dp[i&1][j]=dp[(i+1)&1][j]*j % MOD;
			dp[i&1][j] += dp[(i+1)&1][j+1];
			dp[i&1][j]%= MOD;
		}
	}
	ans++;
	cout<<ans;
	return 0;
}

Compilation message

teams.cpp: In function 'int main()':
teams.cpp:9:16: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&n);
                ^
teams.cpp:12:21: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&ar[i]);
                     ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2172 KB Output is correct
2 Correct 0 ms 2172 KB Output is correct
3 Correct 0 ms 2172 KB Output is correct
4 Correct 0 ms 2172 KB Output is correct
5 Correct 0 ms 2172 KB Output is correct
6 Correct 0 ms 2172 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2172 KB Output is correct
2 Correct 0 ms 2172 KB Output is correct
3 Correct 0 ms 2172 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2172 KB Output is correct
2 Correct 0 ms 2172 KB Output is correct
3 Correct 0 ms 2172 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2172 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2172 KB Output is correct
2 Correct 0 ms 2172 KB Output is correct
3 Correct 0 ms 2172 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2172 KB Output is correct
2 Correct 0 ms 2172 KB Output is correct
3 Correct 0 ms 2172 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2172 KB Output is correct
2 Correct 0 ms 2172 KB Output is correct
3 Correct 3 ms 2172 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 446 ms 2172 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 53 ms 2172 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 249 ms 2172 KB Output isn't correct
2 Halted 0 ms 0 KB -