답안 #24685

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
24685 2017-06-11T20:09:45 Z Bruteforceman Calvinball championship (CEOI15_teams) C++11
70 / 100
23 ms 9908 KB
#include "bits/stdc++.h"
using namespace std;
long long dp[1005][1005];
const int mod = 1000007;

int main(int argc, char const *argv[])
{
	int n;
	scanf("%d", &n);
	for(int i = 0; i <= n; i++) {
		dp[0][i] = 1;
	}
	for(int i = 1; i <= n; i++) {
		for(int j = 1; j <= n; j++) {
			dp[i][j] = dp[i - 1][j] * j + dp[i - 1][j + 1]; 
			dp[i][j] %= mod;
		}
	}
	int *a; 
	a = new int [n + 5];
	for(int i = 1; i <= n; i++) {
		scanf("%d", &a[i]);
	}
	int maxn = 1;
	int ans = 1;
	for(int i = 1; i <= n; i++) {
		for(int j = 1; j < a[i]; j++) {
			ans += dp[n - i][max(maxn, j)]; 
			ans %= mod;
		}
		maxn = max(maxn, a[i]);
	}
	printf("%d\n", ans);
	return 0;	
}

Compilation message

teams.cpp: In function 'int main(int, const char**)':
teams.cpp:9:17: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n);
                 ^
teams.cpp:22:21: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &a[i]);
                     ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 9908 KB Output is correct
2 Correct 0 ms 9908 KB Output is correct
3 Correct 0 ms 9908 KB Output is correct
4 Correct 0 ms 9908 KB Output is correct
5 Correct 0 ms 9908 KB Output is correct
6 Correct 0 ms 9908 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 9908 KB Output is correct
2 Correct 0 ms 9908 KB Output is correct
3 Correct 0 ms 9908 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 9908 KB Output is correct
2 Correct 0 ms 9908 KB Output is correct
3 Correct 0 ms 9908 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 9908 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 9908 KB Output is correct
2 Correct 0 ms 9908 KB Output is correct
3 Correct 0 ms 9908 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 9908 KB Output is correct
2 Correct 0 ms 9908 KB Output is correct
3 Correct 3 ms 9908 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 9908 KB Output is correct
2 Correct 3 ms 9908 KB Output is correct
3 Correct 6 ms 9908 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 19 ms 9908 KB Execution killed with signal 11 (could be triggered by violating memory limits)
# 결과 실행 시간 메모리 Grader output
1 Runtime error 19 ms 9908 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 23 ms 9908 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -