답안 #54780

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
54780 2018-07-05T05:12:04 Z 김세빈(#1509) Calvinball championship (CEOI15_teams) C++11
100 / 100
135 ms 1020 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const ll mod = 1e6 + 7;

ll K[10101], T[10101];
ll D[2][10101];
ll n, ans;

int main()
{
	ll i, j;
	
	scanf("%lld", &n);
	
	for(i=1;i<=n;i++){
		scanf("%lld", K+i);
		T[i] = max(T[i-1], K[i]);
	}
	
	for(i=1;i<=n;i++) D[n&1][i] = 1;
	ans = K[n];
	
	for(i=n-1;i>=1;i--){
		for(j=1;j<=i;j++){
			D[i&1][j] = (D[~i&1][j] * j + D[~i&1][j+1]) % mod;
		}
		ans = (ans + (K[i] - 1) * D[i&1][T[i-1]]) % mod;
	}
	
	printf("%lld\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("%lld", &n);
  ~~~~~^~~~~~~~~~~~
teams.cpp:20:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld", K+i);
   ~~~~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 488 KB Output is correct
3 Correct 2 ms 488 KB Output is correct
4 Correct 2 ms 564 KB Output is correct
5 Correct 2 ms 564 KB Output is correct
6 Correct 3 ms 564 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 564 KB Output is correct
2 Correct 3 ms 564 KB Output is correct
3 Correct 2 ms 564 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 564 KB Output is correct
2 Correct 2 ms 564 KB Output is correct
3 Correct 2 ms 568 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 572 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 576 KB Output is correct
2 Correct 2 ms 576 KB Output is correct
3 Correct 2 ms 576 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 580 KB Output is correct
2 Correct 3 ms 620 KB Output is correct
3 Correct 2 ms 620 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 620 KB Output is correct
2 Correct 3 ms 620 KB Output is correct
3 Correct 4 ms 636 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 109 ms 892 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 33 ms 892 KB Output is correct
2 Correct 29 ms 892 KB Output is correct
3 Correct 30 ms 892 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 135 ms 1020 KB Output is correct
2 Correct 133 ms 1020 KB Output is correct
3 Correct 118 ms 1020 KB Output is correct