답안 #1046521

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1046521 2024-08-06T16:07:49 Z Halym2007 Boat (APIO16_boat) C++17
31 / 100
1394 ms 524288 KB
#include <bits/stdc++.h>
using namespace std;
const int N = 5e2 + 5;
const int NN = 1e6 + 5;
#define ll long long
ll a[N], b[N];
int dp[NN], mod = 1e9 + 7, n, p[NN];
map <ll, int> m;
int main () {
//	freopen ("input.txt", "r", stdin);
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin >> n;
	for (int i = 1; i <= n; ++i) {
		cin >> a[i] >> b[i];
	}
	for (int i = 1; i <= n; ++i) {
		for (int j = a[i]; j <= b[i]; ++j) {
			m[j] = 1;
		}
	}
	int san = 0;
	for (auto i : m) {
		m[i.first] = ++san;
	}
	for (int i = 1; i <= n; ++i) {
		a[i] = m[a[i]]; b[i] = m[b[i]];
	}
	dp[0] = 1;
	for (int i = 1; i <= n; ++i) {
		assert (b[i] <= NN);
		for (int j = 0; j < b[i]; ++j) {
			p[j] = dp[j];
			if (j != 0) {
				p[j] += p[j - 1];
				p[j] %= mod;
			}
		}
		for (int j = b[i]; j >= a[i]; j--) {
			int sum = 0;
			if (j) sum = p[j - 1];
			dp[j] += sum;
			dp[j] %= mod;
		}
	}
	int jog = 0;
	for (int i = 1; i <= san; ++i) {
		jog += dp[i];
		jog %= mod;
	}
	cout << jog;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2556 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2392 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 2392 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 0 ms 2396 KB Output is correct
17 Correct 0 ms 2396 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 0 ms 2396 KB Output is correct
20 Correct 1 ms 2396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2556 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2392 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 2392 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 0 ms 2396 KB Output is correct
17 Correct 0 ms 2396 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 0 ms 2396 KB Output is correct
20 Correct 1 ms 2396 KB Output is correct
21 Correct 34 ms 2844 KB Output is correct
22 Correct 35 ms 2652 KB Output is correct
23 Correct 34 ms 2652 KB Output is correct
24 Correct 37 ms 2652 KB Output is correct
25 Correct 36 ms 2652 KB Output is correct
26 Correct 27 ms 2648 KB Output is correct
27 Correct 26 ms 2652 KB Output is correct
28 Correct 27 ms 2648 KB Output is correct
29 Correct 27 ms 2648 KB Output is correct
30 Correct 740 ms 69972 KB Output is correct
31 Correct 730 ms 68748 KB Output is correct
32 Correct 767 ms 70120 KB Output is correct
33 Correct 760 ms 68288 KB Output is correct
34 Correct 796 ms 68944 KB Output is correct
35 Correct 682 ms 66052 KB Output is correct
36 Correct 695 ms 68176 KB Output is correct
37 Correct 771 ms 68720 KB Output is correct
38 Correct 683 ms 66640 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1394 ms 524288 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2556 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2392 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 2392 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 0 ms 2396 KB Output is correct
17 Correct 0 ms 2396 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 0 ms 2396 KB Output is correct
20 Correct 1 ms 2396 KB Output is correct
21 Correct 34 ms 2844 KB Output is correct
22 Correct 35 ms 2652 KB Output is correct
23 Correct 34 ms 2652 KB Output is correct
24 Correct 37 ms 2652 KB Output is correct
25 Correct 36 ms 2652 KB Output is correct
26 Correct 27 ms 2648 KB Output is correct
27 Correct 26 ms 2652 KB Output is correct
28 Correct 27 ms 2648 KB Output is correct
29 Correct 27 ms 2648 KB Output is correct
30 Correct 740 ms 69972 KB Output is correct
31 Correct 730 ms 68748 KB Output is correct
32 Correct 767 ms 70120 KB Output is correct
33 Correct 760 ms 68288 KB Output is correct
34 Correct 796 ms 68944 KB Output is correct
35 Correct 682 ms 66052 KB Output is correct
36 Correct 695 ms 68176 KB Output is correct
37 Correct 771 ms 68720 KB Output is correct
38 Correct 683 ms 66640 KB Output is correct
39 Runtime error 1394 ms 524288 KB Execution killed with signal 9
40 Halted 0 ms 0 KB -