Submission #24688

# Submission time Handle Problem Language Result Execution time Memory
24688 2017-06-11T20:25:00 Z Bruteforceman Calvinball championship (CEOI15_teams) C++11
70 / 100
76 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;
	a[0] = 0;
	for(int i = 1; i <= n; i++) {
		scanf("%d", &a[i]);
		maxn[i] = max(maxn[i - 1], 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]);
                     ^
# Verdict Execution time Memory 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
# Verdict Execution time Memory 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
# Verdict Execution time Memory 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
# Verdict Execution time Memory Grader output
1 Correct 0 ms 9908 KB Output is correct
# Verdict Execution time Memory 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
# Verdict Execution time Memory Grader output
1 Correct 0 ms 9908 KB Output is correct
2 Correct 0 ms 9908 KB Output is correct
3 Correct 3 ms 9908 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 9908 KB Output is correct
2 Correct 0 ms 9908 KB Output is correct
3 Correct 6 ms 9908 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 76 ms 10060 KB Execution killed with signal 11 (could be triggered by violating memory limits)
# Verdict Execution time Memory Grader output
1 Runtime error 16 ms 9908 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory 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 -