답안 #34351

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
34351 2017-11-10T16:01:20 Z mohammad_kilani Calvinball championship (CEOI15_teams) C++14
60 / 100
1000 ms 6004 KB
#include <bits/stdc++.h>
using namespace std;
#define mod 1000007
#define oo 2000000000
const int N = 1010;
int arr[N] ;
int dp[N][N];
int n;
int solve(int i,int mx){
	if(i == n){
		return 1;
	}
	if(dp[i][mx] != -1) return dp[i][mx];
	dp[i][mx] = 0;
	for(int j=1;j<=mx+1;j++){
		dp[i][mx] += solve(i+1,max(mx,j));
		dp[i][mx] %= mod;
	}
	return dp[i][mx];
}

int main() {
	//freopen("in.txt","r",stdin);
	scanf("%d",&n);
	memset(dp,-1,sizeof(dp));
	for(int i=0;i<n;i++) scanf("%d",&arr[i]);
	int ans = 1 , mx = 0 ;
	for(int i=0;i<n;i++){
		for(int j=1;j<arr[i];j++){
			mx = max(mx,j);
			ans+= solve(i+1,mx);
			ans %= mod;
		}
		mx = max(mx,arr[i]);
	}
	cout << ans << endl;
	return 0;
}

Compilation message

teams.cpp: In function 'int main()':
teams.cpp:24:16: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&n);
                ^
teams.cpp:26:42: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i=0;i<n;i++) scanf("%d",&arr[i]);
                                          ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 6004 KB Output is correct
2 Correct 0 ms 6004 KB Output is correct
3 Correct 0 ms 6004 KB Output is correct
4 Correct 0 ms 6004 KB Output is correct
5 Correct 0 ms 6004 KB Output is correct
6 Correct 0 ms 6004 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 6004 KB Output is correct
2 Correct 3 ms 6004 KB Output is correct
3 Correct 3 ms 6004 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 6004 KB Output is correct
2 Correct 3 ms 6004 KB Output is correct
3 Correct 0 ms 6004 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 6004 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 6004 KB Output is correct
2 Correct 0 ms 6004 KB Output is correct
3 Correct 3 ms 6004 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 156 ms 6004 KB Output is correct
2 Correct 163 ms 6004 KB Output is correct
3 Correct 166 ms 6004 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1000 ms 6004 KB Execution timed out
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 0 ms 6004 KB Execution killed because of forbidden syscall futex (202)
# 결과 실행 시간 메모리 Grader output
1 Runtime error 0 ms 6004 KB Execution killed because of forbidden syscall futex (202)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 0 ms 6004 KB Execution killed because of forbidden syscall futex (202)
2 Halted 0 ms 0 KB -