답안 #24687

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
24687 2017-06-11T20:24:00 Z Bruteforceman Calvinball championship (CEOI15_teams) C++11
20 / 100
73 ms 10064 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);
	int *a; 
	int *maxn;
	a = new int [n + 5];
	maxn = new int [n + 5];

	maxn[0] = 0;
	for(int i = 1; i <= n; i++) {
		scanf("%d", &a[i]);
		maxn[i] = max(maxn[i], a[i]);
	}
	int ans = a[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 idx = n - i;
		for(int j = 1; j < a[idx]; j++) {
			ans += dp[i][max(maxn[idx - 1], j)];
			ans %= mod;
		}
	}
	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:17: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 Incorrect 0 ms 9908 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 9908 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 9908 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 9908 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 9908 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 9908 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 73 ms 10060 KB Execution killed with signal 11 (could be triggered by violating memory limits)
# 결과 실행 시간 메모리 Grader output
1 Runtime error 13 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 26 ms 10064 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -