답안 #531356

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
531356 2022-02-28T13:59:23 Z sidon Calvinball championship (CEOI15_teams) C++17
100 / 100
218 ms 632 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long

const int M = 1e6+7;

int32_t main() {
	int N;
	cin >> N;

	int a[N];
	for(int &i : a) cin >> i, --i;

	int b[N] {a[0]}, res = 1;

	for(int i = 1; i < N; ++i)
		b[i] = max(b[i-1], a[i]);

	vector<int> cur(N+1, 1), dp(N+1);

	for(int i = N; i--; ) {
		swap(cur, dp);

		for(int j = 0; j <= N; ++j)
			cur[j] = ((j + 1 < N ? dp[j + 1] : 0LL) + j * dp[j]) % M;
		res += a[i] * dp[i ? b[i-1] + 1 : 0];
	}

	cout << (res % M);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 292 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 292 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 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 296 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 288 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 288 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 3 ms 292 KB Output is correct
2 Correct 4 ms 204 KB Output is correct
3 Correct 3 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 206 ms 620 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 58 ms 436 KB Output is correct
2 Correct 54 ms 332 KB Output is correct
3 Correct 56 ms 452 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 210 ms 612 KB Output is correct
2 Correct 218 ms 608 KB Output is correct
3 Correct 205 ms 632 KB Output is correct