답안 #672249

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
672249 2022-12-15T08:28:39 Z Dan4Life Boat (APIO16_boat) C++17
31 / 100
1437 ms 524288 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define fi first
#define se second
const int maxn = 5e2+10;
const int MOD = (int)1e9+7;
pair<int,int> a[maxn];
vector<int> dp[maxn];
int n;

int32_t main() {
	cin >> n; int ans = 0;
	for(int i = 0; i < n; i++) cin >> a[i].fi >> a[i].se;
	for(int i = 0; i < n; i++){
		dp[i].resize(a[i].se-a[i].fi+1,0);
		int x = a[i].fi;
		for(int j = 0; j <= a[i].se-x; j++){
			dp[i][j]=1; 
			if(j) dp[i][j]+=dp[i][j-1];
			if(dp[i][j]>MOD) dp[i][j]-=MOD;
			for(int k = 0; k < i; k++){
				if(j+x>a[k].fi) dp[i][j]+=dp[k][min(j+x-1,a[k].se)-a[k].fi];
				if(dp[i][j]>MOD) dp[i][j]-=MOD;
			}
		}
	}
	for(int i = 0; i < n; i++) ans+=dp[i][a[i].se-a[i].fi], ans-=(ans>MOD?MOD:0);
	cout << ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 2 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 2 ms 212 KB Output is correct
21 Correct 1414 ms 3680 KB Output is correct
22 Correct 1392 ms 3680 KB Output is correct
23 Correct 1260 ms 3500 KB Output is correct
24 Correct 1407 ms 3724 KB Output is correct
25 Correct 1383 ms 3796 KB Output is correct
26 Correct 1356 ms 4044 KB Output is correct
27 Correct 1411 ms 4100 KB Output is correct
28 Correct 1376 ms 4076 KB Output is correct
29 Correct 1437 ms 4096 KB Output is correct
30 Correct 1394 ms 4148 KB Output is correct
31 Correct 1383 ms 4300 KB Output is correct
32 Correct 1382 ms 4188 KB Output is correct
33 Correct 1331 ms 4300 KB Output is correct
34 Correct 1363 ms 4276 KB Output is correct
35 Correct 724 ms 3928 KB Output is correct
36 Correct 852 ms 3992 KB Output is correct
37 Correct 831 ms 4028 KB Output is correct
38 Correct 857 ms 3916 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 222 ms 524288 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 2 ms 212 KB Output is correct
21 Correct 1414 ms 3680 KB Output is correct
22 Correct 1392 ms 3680 KB Output is correct
23 Correct 1260 ms 3500 KB Output is correct
24 Correct 1407 ms 3724 KB Output is correct
25 Correct 1383 ms 3796 KB Output is correct
26 Correct 1356 ms 4044 KB Output is correct
27 Correct 1411 ms 4100 KB Output is correct
28 Correct 1376 ms 4076 KB Output is correct
29 Correct 1437 ms 4096 KB Output is correct
30 Correct 1394 ms 4148 KB Output is correct
31 Correct 1383 ms 4300 KB Output is correct
32 Correct 1382 ms 4188 KB Output is correct
33 Correct 1331 ms 4300 KB Output is correct
34 Correct 1363 ms 4276 KB Output is correct
35 Correct 724 ms 3928 KB Output is correct
36 Correct 852 ms 3992 KB Output is correct
37 Correct 831 ms 4028 KB Output is correct
38 Correct 857 ms 3916 KB Output is correct
39 Runtime error 222 ms 524288 KB Execution killed with signal 9
40 Halted 0 ms 0 KB -