Submission #221650

# Submission time Handle Problem Language Result Execution time Memory
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]);
   ~~~~~^~~~~~~~~~~~
# Verdict Execution time Memory 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
# Verdict Execution time Memory 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
# Verdict Execution time Memory 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
# Verdict Execution time Memory Grader output
1 Correct 6 ms 4352 KB Output is correct
# Verdict Execution time Memory 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
# Verdict Execution time Memory 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
# Verdict Execution time Memory 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
# Verdict Execution time Memory Grader output
1 Incorrect 12 ms 4344 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 4352 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 4352 KB Output isn't correct
2 Halted 0 ms 0 KB -