답안 #527357

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
527357 2022-02-17T09:41:45 Z siewjh Calvinball championship (CEOI15_teams) C++17
70 / 100
81 ms 484 KB
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
using namespace std;
const int mod = 1'000'007;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int nums;  cin >> nums;
	vector<int> vec(nums + 1), pmax(nums + 1, 0);
	for (int i = 1; i <= nums; i++) {
		cin >> vec[i];
		pmax[i] = max(pmax[i - 1], vec[i]);
	}
	vector<vector<int>> memo(2, vector<int>(nums + 1, 0));
	bool prev = 0;
	for (int i = 1; i < nums; i++) memo[0][i] = 1;
	int ans = 0;
	for (int i = nums; i >= 1; i--) {
		ans += (memo[prev][pmax[i - 1]] * (vec[i] - 1)) % mod;
		ans %= mod;
		for (int j = 1; j < i; j++) memo[1 - prev][j] = (j * memo[prev][j] + memo[prev][j + 1]) % mod;
		prev = 1 - prev;
	}
	cout << ans + 1;
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 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 0 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 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 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 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 0 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 204 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 Incorrect 79 ms 484 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 21 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 81 ms 484 KB Output isn't correct
2 Halted 0 ms 0 KB -