답안 #281189

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
281189 2020-08-23T03:49:47 Z AQT Calvinball championship (CEOI15_teams) C++14
80 / 100
896 ms 65540 KB
#include <bits/stdc++.h>

using namespace std;

int N;
int arr[10005];
long long dp[4005][10005];
const long long MOD = 1000007;

long long solve(int n, int m, bool border){
	if(n == N+1){
		return 1;
	}
	if(!border && n%3 == 0 && dp[n/3][m]){
		return dp[n/3][m];
	}
	int lim = m+1;
	if(border){
		lim = arr[n];
	}
	long long ans = 0;
	ans += (lim-1) * solve(n+1, m, 0);
	ans += solve(n+1, max(lim, m), border);
	ans %= MOD;
	if(!border && n%3 == 0){
		dp[n/3][m] = ans;
	}
	return ans;
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >> N;
	for(int i = 1; i<=N; i++){
		cin >> arr[i];
	}
	cout << solve(1, 0, 1);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 544 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 512 KB Output is correct
2 Correct 1 ms 512 KB Output is correct
3 Correct 1 ms 512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 1384 KB Output is correct
2 Correct 5 ms 1408 KB Output is correct
3 Correct 6 ms 1408 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 24 ms 3072 KB Output is correct
2 Correct 25 ms 3064 KB Output is correct
3 Correct 17 ms 3072 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 840 ms 65540 KB Execution killed with signal 9
# 결과 실행 시간 메모리 Grader output
1 Correct 503 ms 40168 KB Output is correct
2 Correct 511 ms 40052 KB Output is correct
3 Correct 459 ms 40056 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 896 ms 65540 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -