# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
875593 |
2023-11-20T06:32:07 Z |
NeroZein |
Boat (APIO16_boat) |
C++17 |
|
1036 ms |
524288 KB |
#include "bits/stdc++.h"
using namespace std;
#ifdef Nero
#include "Deb.h"
#else
#define deb(...)
#endif
const int md = (int) 1e9 + 7;
void add(int& a, int b) {
a += b;
if (a >= md) a -= md;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n;
cin >> n;
vector<int> a(n), b(n), c;
for (int i = 0; i < n; ++i) {
cin >> a[i] >> b[i];
for (int j = a[i]; j <= b[i]; ++j) {
c.push_back(j);
}
}
sort(c.begin(), c.end());
c.resize(unique(c.begin(), c.end()) - c.begin());
vector<int> dp(n);
for (int i : c) {
vector<int> pd(n);
for (int j = 0; j < n; ++j) {
pd[j] = dp[j];
dp[j] = 0;
}
int s = 1;
for (int j = 0; j < n; ++j) {
dp[j] = pd[j];
if (a[j] <= i && b[j] >= i) {
add(dp[j], s);
}
add(s, pd[j]);
}
}
int ans = 0;
for (int i = 0; i < n; ++i) {
add(ans, dp[i]);
}
cout << ans << '\n';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
460 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
484 KB |
Output is correct |
14 |
Correct |
1 ms |
344 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
1 ms |
348 KB |
Output is correct |
19 |
Correct |
1 ms |
348 KB |
Output is correct |
20 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
460 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
484 KB |
Output is correct |
14 |
Correct |
1 ms |
344 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
1 ms |
348 KB |
Output is correct |
19 |
Correct |
1 ms |
348 KB |
Output is correct |
20 |
Correct |
1 ms |
348 KB |
Output is correct |
21 |
Correct |
37 ms |
6612 KB |
Output is correct |
22 |
Correct |
35 ms |
5844 KB |
Output is correct |
23 |
Correct |
32 ms |
6356 KB |
Output is correct |
24 |
Correct |
35 ms |
6356 KB |
Output is correct |
25 |
Correct |
35 ms |
5588 KB |
Output is correct |
26 |
Correct |
35 ms |
4820 KB |
Output is correct |
27 |
Correct |
36 ms |
6356 KB |
Output is correct |
28 |
Correct |
39 ms |
6364 KB |
Output is correct |
29 |
Correct |
36 ms |
6356 KB |
Output is correct |
30 |
Correct |
1036 ms |
6356 KB |
Output is correct |
31 |
Correct |
1010 ms |
6612 KB |
Output is correct |
32 |
Correct |
1012 ms |
5332 KB |
Output is correct |
33 |
Correct |
989 ms |
5332 KB |
Output is correct |
34 |
Correct |
991 ms |
4564 KB |
Output is correct |
35 |
Correct |
956 ms |
5076 KB |
Output is correct |
36 |
Correct |
984 ms |
5444 KB |
Output is correct |
37 |
Correct |
1025 ms |
5844 KB |
Output is correct |
38 |
Correct |
967 ms |
5588 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
401 ms |
524288 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
460 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
484 KB |
Output is correct |
14 |
Correct |
1 ms |
344 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
1 ms |
348 KB |
Output is correct |
19 |
Correct |
1 ms |
348 KB |
Output is correct |
20 |
Correct |
1 ms |
348 KB |
Output is correct |
21 |
Correct |
37 ms |
6612 KB |
Output is correct |
22 |
Correct |
35 ms |
5844 KB |
Output is correct |
23 |
Correct |
32 ms |
6356 KB |
Output is correct |
24 |
Correct |
35 ms |
6356 KB |
Output is correct |
25 |
Correct |
35 ms |
5588 KB |
Output is correct |
26 |
Correct |
35 ms |
4820 KB |
Output is correct |
27 |
Correct |
36 ms |
6356 KB |
Output is correct |
28 |
Correct |
39 ms |
6364 KB |
Output is correct |
29 |
Correct |
36 ms |
6356 KB |
Output is correct |
30 |
Correct |
1036 ms |
6356 KB |
Output is correct |
31 |
Correct |
1010 ms |
6612 KB |
Output is correct |
32 |
Correct |
1012 ms |
5332 KB |
Output is correct |
33 |
Correct |
989 ms |
5332 KB |
Output is correct |
34 |
Correct |
991 ms |
4564 KB |
Output is correct |
35 |
Correct |
956 ms |
5076 KB |
Output is correct |
36 |
Correct |
984 ms |
5444 KB |
Output is correct |
37 |
Correct |
1025 ms |
5844 KB |
Output is correct |
38 |
Correct |
967 ms |
5588 KB |
Output is correct |
39 |
Runtime error |
401 ms |
524288 KB |
Execution killed with signal 9 |
40 |
Halted |
0 ms |
0 KB |
- |