Submission #545887

# Submission time Handle Problem Language Result Execution time Memory
545887 2022-04-05T15:53:57 Z rainboy Calvinball championship (CEOI15_teams) C
100 / 100
127 ms 352 KB
#include <stdio.h>

#define N	10000
#define MD	1000007

int main() {
	static int dp[N + 1];
	int n, k, k_, i, ans;

	scanf("%d", &n);
	k_ = 0;
	for (i = 0; i < n; i++) {
		int a;

		scanf("%d", &a);
		for (k = i + 1; k >= 0; k--)
			dp[k] = ((long long) dp[k] * k + (k == 0 ? 0 : dp[k - 1])) % MD;
		dp[k_] = (dp[k_] + a - 1) % MD;
		if (a == k_ + 1)
			k_++;
	}
	ans = 1;
	for (k = 1; k <= n; k++)
		ans = (ans + dp[k]) % MD;
	printf("%d\n", ans);
	return 0;
}

Compilation message

teams.c: In function 'main':
teams.c:10:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |  scanf("%d", &n);
      |  ^~~~~~~~~~~~~~~
teams.c:15:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |   scanf("%d", &a);
      |   ^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 292 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 292 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 296 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 288 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 292 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 212 KB Output is correct
2 Correct 2 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 95 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 24 ms 212 KB Output is correct
2 Correct 27 ms 212 KB Output is correct
3 Correct 26 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 127 ms 336 KB Output is correct
2 Correct 99 ms 332 KB Output is correct
3 Correct 98 ms 352 KB Output is correct