답안 #107820

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
107820 2019-04-25T23:53:28 Z luciocf Calvinball championship (CEOI15_teams) C++14
70 / 100
200 ms 66560 KB
#include <bits/stdc++.h>

using namespace std;

const int maxn = 1e4+10;
const int mod = 1e6+7;

int a[maxn];

int dp[maxn][maxn];

void add(int &a, int b)
{
	a = (a+b)%mod;
}

int main(void)
{
	int n;
	scanf("%d", &n);

	for (int i = 1; i <= n; i++)
		scanf("%d", &a[i]);

	for (int i = 1; i <= n; i++) dp[0][i] = 1;

	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j <= n; j++)
		{
			add(dp[i][j], (1ll*j*dp[i-1][j])%mod);
			add(dp[i][j], dp[i-1][j+1]);
		}
	}

	int ans = 1, mx = 1;
	for (int i = 1; i <= n; i++)
	{
		for (int j = a[i]-1; j >= 1; j--)
			add(ans, dp[n-i][max(mx, j)]);

		mx = max(a[i], mx);
	}

	printf("%d\n", ans);
}

Compilation message

teams.cpp: In function 'int main()':
teams.cpp:20:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n);
  ~~~~~^~~~~~~~~~
teams.cpp:23:8: 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 2 ms 384 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 3 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 3 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 768 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 768 KB Output is correct
2 Correct 3 ms 768 KB Output is correct
3 Correct 3 ms 768 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 3328 KB Output is correct
2 Correct 7 ms 3328 KB Output is correct
3 Correct 7 ms 3328 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 19 ms 8312 KB Output is correct
2 Correct 18 ms 8284 KB Output is correct
3 Correct 20 ms 8320 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 198 ms 66560 KB Execution killed with signal 9 (could be triggered by violating memory limits)
# 결과 실행 시간 메모리 Grader output
1 Runtime error 200 ms 66560 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 174 ms 66560 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -