답안 #40846

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
40846 2018-02-09T12:20:04 Z IvanC Boat (APIO16_boat) C++14
9 / 100
2000 ms 524288 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = 501;
const ll MOD = (ll)1e9 + 7;
ll A[MAXN],B[MAXN],N;
vector<ll> dp[MAXN],sum[MAXN];
ll get_sum(ll idx,ll i,ll j){
	i -= A[idx];
	j -= A[idx];
	i = max(i,0LL);
	if(i > j) return 0;
	if(i == 0) return sum[idx][j];
	else return sum[idx][j] - sum[idx][i-1];
}
int main(){
	cin >> N;
	for(int i = 1;i<=N;i++){
		cin >> A[i] >> B[i];
		for(ll j = A[i];j<=B[i];j++){
			dp[i].push_back(0);
			sum[i].push_back(0);
		}
	}
	for(ll j = A[N];j<=B[N];j++){
		dp[N][j - A[N]] = 1;
		sum[N][j - A[N]] = dp[N][j - A[N]];
		if(j - A[N] != 0) sum[N][j - A[N]] += sum[N][j - A[N] - 1]; 
	}
	for(ll i = N-1;i>=1;i--){
		for(ll j = A[i];j<=B[i];j++){
			dp[i][j - A[i]] = 1;
			for(ll k = i+1;k<=N;k++){
				dp[i][j - A[i]] = (dp[i][j - A[i]] + get_sum(k,j+1,B[k])) % MOD;
			}
		}
		for(ll j = A[i];j<=B[i];j++){
			sum[i][j - A[i]] = dp[i][j - A[i]];
			if(j - A[i] != 0) sum[i][j - A[i]] += sum[i][j - A[i] - 1];
			sum[i][j - A[i]] %= MOD;
		}
	}
	ll tot = 0;
	for(ll i = 1;i<=N;i++) tot = (tot + sum[i].back()) % MOD;
	if(tot < 0) tot += MOD;
	cout << tot << endl;
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 4 ms 488 KB Output is correct
3 Correct 4 ms 488 KB Output is correct
4 Correct 3 ms 648 KB Output is correct
5 Correct 3 ms 648 KB Output is correct
6 Correct 4 ms 648 KB Output is correct
7 Correct 3 ms 648 KB Output is correct
8 Correct 4 ms 648 KB Output is correct
9 Correct 3 ms 648 KB Output is correct
10 Correct 3 ms 648 KB Output is correct
11 Correct 3 ms 648 KB Output is correct
12 Correct 3 ms 648 KB Output is correct
13 Correct 3 ms 648 KB Output is correct
14 Correct 4 ms 648 KB Output is correct
15 Correct 3 ms 648 KB Output is correct
16 Correct 3 ms 648 KB Output is correct
17 Correct 4 ms 648 KB Output is correct
18 Correct 3 ms 648 KB Output is correct
19 Correct 3 ms 648 KB Output is correct
20 Correct 3 ms 648 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 4 ms 488 KB Output is correct
3 Correct 4 ms 488 KB Output is correct
4 Correct 3 ms 648 KB Output is correct
5 Correct 3 ms 648 KB Output is correct
6 Correct 4 ms 648 KB Output is correct
7 Correct 3 ms 648 KB Output is correct
8 Correct 4 ms 648 KB Output is correct
9 Correct 3 ms 648 KB Output is correct
10 Correct 3 ms 648 KB Output is correct
11 Correct 3 ms 648 KB Output is correct
12 Correct 3 ms 648 KB Output is correct
13 Correct 3 ms 648 KB Output is correct
14 Correct 4 ms 648 KB Output is correct
15 Correct 3 ms 648 KB Output is correct
16 Correct 3 ms 648 KB Output is correct
17 Correct 4 ms 648 KB Output is correct
18 Correct 3 ms 648 KB Output is correct
19 Correct 3 ms 648 KB Output is correct
20 Correct 3 ms 648 KB Output is correct
21 Execution timed out 2036 ms 17908 KB Time limit exceeded
22 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 820 ms 524288 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 4 ms 488 KB Output is correct
3 Correct 4 ms 488 KB Output is correct
4 Correct 3 ms 648 KB Output is correct
5 Correct 3 ms 648 KB Output is correct
6 Correct 4 ms 648 KB Output is correct
7 Correct 3 ms 648 KB Output is correct
8 Correct 4 ms 648 KB Output is correct
9 Correct 3 ms 648 KB Output is correct
10 Correct 3 ms 648 KB Output is correct
11 Correct 3 ms 648 KB Output is correct
12 Correct 3 ms 648 KB Output is correct
13 Correct 3 ms 648 KB Output is correct
14 Correct 4 ms 648 KB Output is correct
15 Correct 3 ms 648 KB Output is correct
16 Correct 3 ms 648 KB Output is correct
17 Correct 4 ms 648 KB Output is correct
18 Correct 3 ms 648 KB Output is correct
19 Correct 3 ms 648 KB Output is correct
20 Correct 3 ms 648 KB Output is correct
21 Execution timed out 2036 ms 17908 KB Time limit exceeded
22 Halted 0 ms 0 KB -