답안 #527127

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
527127 2022-02-17T02:25:35 Z hmm789 Calvinball championship (CEOI15_teams) C++14
70 / 100
38 ms 65540 KB
#include <bits/stdc++.h>
using namespace std;

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	#define int long long
	#define MOD 1000007
	int n, ans = 0, mx = 0;
	cin >> n;
	int a[n];
	for(int i = 0; i < n; i++) cin >> a[i];
	int dp[n][n+1], npow = 1;
	for(int i = 0; i < n; i++) {
		dp[i][n] = npow;
		npow *= n;
		npow %= MOD;
	}
	for(int i = 0; i < n; i++) {
		for(int j = n-1; j >= 0; j--) {
			if(i == 0) dp[i][j] = 1;
			else dp[i][j] = j*dp[i-1][j] + dp[i-1][j+1];
			dp[i][j] %= MOD;
		}
	}
	for(int i = 0; i < n; i++) {
		ans += (a[i]-1)*dp[n-i-1][mx];
		mx = max(mx, a[i]);
		ans %= MOD;
	}
	cout << (ans+1)%MOD;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 308 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 312 KB Output is correct
6 Correct 1 ms 308 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 308 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2256 KB Output is correct
2 Correct 2 ms 2252 KB Output is correct
3 Correct 2 ms 2252 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 8124 KB Output is correct
2 Correct 8 ms 8140 KB Output is correct
3 Correct 6 ms 8116 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 38 ms 65540 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 35 ms 65540 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 36 ms 65540 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -