답안 #401489

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
401489 2021-05-10T11:55:25 Z BERNARB01 Boat (APIO16_boat) C++17
9 / 100
2000 ms 524292 KB
#include <bits/stdc++.h>

using namespace std;

const int mod = (int) 1e9 + 7;
const int N = 502;

int n, a[N], b[N];
long long dp[N][N];
map<int, int> mp;

long long sol(int i, int hi) {
	if (i == n) {
		return (hi > 0);
	}
	long long& ret = dp[i][hi];
	if (ret != -1) {
		return ret;
	}
	ret = sol(i + 1, hi);
	for (int j = a[i]; j <= b[i]; j++) {
		if (j > hi) {
			ret += sol(i + 1, j);
			ret %= mod;
		}
	}
	return ret;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	memset(dp, -1, sizeof dp);
	cin >> n;
	vector<int> se;
	for (int i = 0; i < n; i++) {
		cin >> a[i] >> b[i];
		for (int j = a[i]; j <= b[i]; j++) {
			se.push_back(j);
		}
	}
	sort(se.begin(), se.end());
	int idd = 1;
	for (int i = 0; i < (int) se.size(); i++) {
		if (i == 0 || se[i] != se[i - 1]) {
			mp[se[i]] = idd++;
		}
	}
	for (int i = 0; i < n; i++) {
		a[i] = mp[a[i]];
		b[i] = mp[b[i]];
	}
	cout << sol(0, 0) << '\n';
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 2252 KB Output is correct
2 Correct 4 ms 2252 KB Output is correct
3 Correct 4 ms 2352 KB Output is correct
4 Correct 4 ms 2252 KB Output is correct
5 Correct 4 ms 2356 KB Output is correct
6 Correct 4 ms 2252 KB Output is correct
7 Correct 4 ms 2252 KB Output is correct
8 Correct 4 ms 2252 KB Output is correct
9 Correct 4 ms 2252 KB Output is correct
10 Correct 4 ms 2252 KB Output is correct
11 Correct 4 ms 2252 KB Output is correct
12 Correct 4 ms 2252 KB Output is correct
13 Correct 5 ms 2252 KB Output is correct
14 Correct 4 ms 2252 KB Output is correct
15 Correct 4 ms 2252 KB Output is correct
16 Correct 2 ms 2336 KB Output is correct
17 Correct 2 ms 2252 KB Output is correct
18 Correct 2 ms 2252 KB Output is correct
19 Correct 2 ms 2252 KB Output is correct
20 Correct 2 ms 2252 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 2252 KB Output is correct
2 Correct 4 ms 2252 KB Output is correct
3 Correct 4 ms 2352 KB Output is correct
4 Correct 4 ms 2252 KB Output is correct
5 Correct 4 ms 2356 KB Output is correct
6 Correct 4 ms 2252 KB Output is correct
7 Correct 4 ms 2252 KB Output is correct
8 Correct 4 ms 2252 KB Output is correct
9 Correct 4 ms 2252 KB Output is correct
10 Correct 4 ms 2252 KB Output is correct
11 Correct 4 ms 2252 KB Output is correct
12 Correct 4 ms 2252 KB Output is correct
13 Correct 5 ms 2252 KB Output is correct
14 Correct 4 ms 2252 KB Output is correct
15 Correct 4 ms 2252 KB Output is correct
16 Correct 2 ms 2336 KB Output is correct
17 Correct 2 ms 2252 KB Output is correct
18 Correct 2 ms 2252 KB Output is correct
19 Correct 2 ms 2252 KB Output is correct
20 Correct 2 ms 2252 KB Output is correct
21 Execution timed out 2089 ms 6468 KB Time limit exceeded
22 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 542 ms 524292 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 2252 KB Output is correct
2 Correct 4 ms 2252 KB Output is correct
3 Correct 4 ms 2352 KB Output is correct
4 Correct 4 ms 2252 KB Output is correct
5 Correct 4 ms 2356 KB Output is correct
6 Correct 4 ms 2252 KB Output is correct
7 Correct 4 ms 2252 KB Output is correct
8 Correct 4 ms 2252 KB Output is correct
9 Correct 4 ms 2252 KB Output is correct
10 Correct 4 ms 2252 KB Output is correct
11 Correct 4 ms 2252 KB Output is correct
12 Correct 4 ms 2252 KB Output is correct
13 Correct 5 ms 2252 KB Output is correct
14 Correct 4 ms 2252 KB Output is correct
15 Correct 4 ms 2252 KB Output is correct
16 Correct 2 ms 2336 KB Output is correct
17 Correct 2 ms 2252 KB Output is correct
18 Correct 2 ms 2252 KB Output is correct
19 Correct 2 ms 2252 KB Output is correct
20 Correct 2 ms 2252 KB Output is correct
21 Execution timed out 2089 ms 6468 KB Time limit exceeded
22 Halted 0 ms 0 KB -