Submission #154207

# Submission time Handle Problem Language Result Execution time Memory
154207 2019-09-19T07:58:15 Z junodeveloper Calvinball championship (CEOI15_teams) C++14
70 / 100
200 ms 604 KB
#include <bits/stdc++.h>
#define sz(x) ((int)x.size())
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int mod = 1e6+7;
int n,a[10010],b[10010];
int dp[2][10010];
int main() {
	scanf("%d",&n);
	int i,j;
	for(i=1;i<=n;i++)scanf("%d",a+i),b[i]=max(b[i-1],a[i]);
	int res=0;
	for(i=1;i<=n+1;i++) dp[1-n%2][i]=1;
	for(i=n;i>=1;i--) {
		res+=(a[i]-1)*dp[1-i%2][b[i-1]]%mod;
		res%=mod;
		for(j=1;j<=i;j++) {
			dp[i%2][j]=((ll)dp[1-i%2][j]*j%mod+dp[1-i%2][j+1])%mod;
		}
	}
	printf("%d",res+1);
	return 0;
}

Compilation message

teams.cpp: In function 'int main()':
teams.cpp:15:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&n);
  ~~~~~^~~~~~~~~
teams.cpp:17:34: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(i=1;i<=n;i++)scanf("%d",a+i),b[i]=max(b[i-1],a[i]);
                   ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 3 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
3 Correct 3 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 376 KB Output is correct
2 Correct 4 ms 376 KB Output is correct
3 Correct 4 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 193 ms 560 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 52 ms 376 KB Output is correct
2 Correct 52 ms 504 KB Output is correct
3 Incorrect 52 ms 604 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 200 ms 504 KB Output is correct
2 Correct 199 ms 544 KB Output is correct
3 Incorrect 200 ms 564 KB Output isn't correct