답안 #221650

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
221650 2020-04-10T19:10:35 Z Lawliet Calvinball championship (CEOI15_teams) C++17
70 / 100
12 ms 4352 KB
#include <bits/stdc++.h>

using namespace std;

const int MAXN = 1010;
const int MOD = 1000007;

int n;

int v[MAXN];
int dp[MAXN][MAXN];

int solve(int i, int j)
{
	int& ans = dp[i][j];

	if( ans != -1 ) return ans;

	if( i == n + 1 ) return ans = 1;

	ans = solve( i + 1 , j + 1 );
	ans += j*solve( i + 1 , j );

	ans %= MOD;
	
	return ans;
}

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

	memset( dp , -1 , sizeof(dp) );

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

	int ans = 0;
	int maxValue = 0;

	for(int i = 1 ; i <= n ; i++)
	{
		ans += solve( i + 1 , maxValue )*( v[i] - 1 );

		maxValue = max( maxValue , v[i] );

		ans %= MOD;
	}

	ans++;
	ans %= MOD;

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

Compilation message

teams.cpp: In function 'int main()':
teams.cpp:31:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&n);
  ~~~~~^~~~~~~~~
teams.cpp:36:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&v[i]);
   ~~~~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 4352 KB Output is correct
2 Correct 7 ms 4352 KB Output is correct
3 Correct 6 ms 4352 KB Output is correct
4 Correct 6 ms 4352 KB Output is correct
5 Correct 7 ms 4352 KB Output is correct
6 Correct 7 ms 4352 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 4352 KB Output is correct
2 Correct 7 ms 4352 KB Output is correct
3 Correct 8 ms 4352 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 4352 KB Output is correct
2 Correct 6 ms 4224 KB Output is correct
3 Correct 6 ms 4352 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 4352 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 4352 KB Output is correct
2 Correct 7 ms 4352 KB Output is correct
3 Correct 6 ms 4352 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 4352 KB Output is correct
2 Correct 9 ms 4352 KB Output is correct
3 Correct 8 ms 4352 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 4352 KB Output is correct
2 Correct 12 ms 4352 KB Output is correct
3 Correct 12 ms 4352 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 12 ms 4344 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 7 ms 4352 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 4352 KB Output isn't correct
2 Halted 0 ms 0 KB -