Submission #49177

# Submission time Handle Problem Language Result Execution time Memory
49177 2018-05-23T06:32:31 Z Namnamseo Calvinball championship (CEOI15_teams) C++17
100 / 100
418 ms 1360 KB
#include <cstdio>
#include <algorithm>
using namespace std;

const int M=1000007;
typedef long long ll;

int data[10010];

ll dp[10010];
int pM[10010];
ll pr[10010];
int Mv;
int n;

int main(){
	scanf("%d", &n);
	for(int i=1; i<=n; ++i){
		int x;
		scanf("%d", &x);

		if(Mv < x) Mv = x;
		data[i] = x;
	}

	int ans=1;
	for(int i=1; i<=n; ++i) pM[i] = max(pM[i-1], data[i]);
	for(int i=1; i<=n+1; ++i) dp[i]=1, pr[i]=pr[i-1]+dp[i];
	for(int i=n; 2<=i; --i){
		int x = data[i];
		ans += (x-1) * ll(dp[pM[i-1]]) % M;
		ans %= M;
		for(int j=1; j<=i; ++j){
			dp[j] = (dp[j]*j + dp[j+1])%M;
			pr[j] = (pr[j-1] + dp[j])%M;
		}
	}
	printf("%d\n", ans);
	return 0;
}

Compilation message

teams.cpp: In function 'int main()':
teams.cpp:17:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n);
  ~~~~~^~~~~~~~~~
teams.cpp:20:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &x);
   ~~~~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 4 ms 632 KB Output is correct
2 Correct 2 ms 632 KB Output is correct
3 Correct 2 ms 632 KB Output is correct
4 Correct 2 ms 632 KB Output is correct
5 Correct 2 ms 684 KB Output is correct
6 Correct 2 ms 684 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 696 KB Output is correct
2 Correct 2 ms 792 KB Output is correct
3 Correct 2 ms 820 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 820 KB Output is correct
2 Correct 2 ms 820 KB Output is correct
3 Correct 2 ms 820 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 820 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 820 KB Output is correct
2 Correct 2 ms 820 KB Output is correct
3 Correct 2 ms 820 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 908 KB Output is correct
2 Correct 4 ms 912 KB Output is correct
3 Correct 3 ms 916 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 920 KB Output is correct
2 Correct 8 ms 924 KB Output is correct
3 Correct 6 ms 928 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 386 ms 1180 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 102 ms 1180 KB Output is correct
2 Correct 106 ms 1180 KB Output is correct
3 Correct 102 ms 1192 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 418 ms 1360 KB Output is correct
2 Correct 395 ms 1360 KB Output is correct
3 Correct 384 ms 1360 KB Output is correct