답안 #40414

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
40414 2018-02-01T12:09:22 Z Pajaraja Calvinball championship (CEOI15_teams) C++14
100 / 100
367 ms 1436 KB
#include <bits/stdc++.h>
using namespace std;
const int MOD=1000007;
long long dp[10007],dpl[10007];
long long a[10007],parc[10007];
int main()
{
	long long cur=0;
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	parc[0]=0;
	for(int i=1;i<=n;i++) parc[i]=fmax(parc[i-1],a[i]);
	for(int i=1;i<=n;i++) dp[i]=1;
	for(int j=n;j>=1;j--)
	{
		cur=(cur+dp[parc[j-1]]*(min(parc[j-1],a[j]-1)))%MOD;
		for(int i=parc[j-1]+1;i<a[j];i++) cur=(cur+dp[i])%MOD;
		for(int i=1;i<=n;i++) dpl[i]=dp[i];
		for(int i=1;i<=n;i++) dp[i]=(i*dpl[i]+dpl[i+1])%MOD;
	}
	printf("%d",cur+1);
}

Compilation message

teams.cpp: In function 'int main()':
teams.cpp:11:40: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'long long int*' [-Wformat=]
  for(int i=1;i<=n;i++) scanf("%d",&a[i]);
                                        ^
teams.cpp:22:19: warning: format '%d' expects argument of type 'int', but argument 2 has type 'long long int' [-Wformat=]
  printf("%d",cur+1);
                   ^
teams.cpp:10:16: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&n);
                ^
teams.cpp:11:41: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i=1;i<=n;i++) scanf("%d",&a[i]);
                                         ^
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 356 KB Output is correct
3 Correct 1 ms 432 KB Output is correct
4 Correct 2 ms 452 KB Output is correct
5 Correct 2 ms 512 KB Output is correct
6 Correct 2 ms 548 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 552 KB Output is correct
2 Correct 2 ms 556 KB Output is correct
3 Correct 2 ms 576 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 584 KB Output is correct
2 Correct 2 ms 648 KB Output is correct
3 Correct 2 ms 664 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 668 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 672 KB Output is correct
2 Correct 2 ms 676 KB Output is correct
3 Correct 2 ms 680 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 684 KB Output is correct
2 Correct 4 ms 688 KB Output is correct
3 Correct 2 ms 692 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 696 KB Output is correct
2 Correct 5 ms 700 KB Output is correct
3 Correct 5 ms 704 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 367 ms 1060 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 74 ms 1060 KB Output is correct
2 Correct 75 ms 1060 KB Output is correct
3 Correct 75 ms 1060 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 298 ms 1188 KB Output is correct
2 Correct 288 ms 1188 KB Output is correct
3 Correct 293 ms 1436 KB Output is correct