# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1027553 |
2024-07-19T07:29:19 Z |
stdfloat |
Boat (APIO16_boat) |
C++17 |
|
2000 ms |
524116 KB |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int md = (int)1e9 + 7;
int main() {
ios::sync_with_stdio(false); cin.tie(nullptr);
int n;
cin >> n;
vector<int> a(n), b(n);
for (int i = 0; i < n; i++) cin >> a[i] >> b[i];
map<int, int> m;
for (int i = 0; i < n; i++) {
for (int j = a[i]; j <= b[i]; j++) m[j] = 1;
}
int x = 0;
for (auto &i : m) i.second = ++x;
vector<int> fn(x + 1), dp(x + 1);
for (int i = 0; i < n; i++) {
int sm = 0;
for (int j = m[b[i]]; j > 0; j -= j & -j) sm = (sm + fn[j]) % md;
// cout << "\ni " << i << ' ' << sm << '\n';
for (int j = m[b[i]]; j >= m[a[i]]; j--) {
sm = ((sm - dp[j]) % md + md) % md;
dp[j] = (dp[j] + sm + 1) % md;
// cout << "j " << j << ' ' << sm + 1 << '\n';
for (int k = j; k <= x; k += k & -k) fn[k] = (fn[k] + sm + 1) % md;
// for (int k = 1; k < j; k++) dp[j] = (dp[j] + dp[k]) % md;
}
}
int sm = 0;
for (auto i : dp) sm = (sm + i) % md;
cout << sm << '\n';
}
/*sub1
vector<int> dp(n);
for (int i = 0; i < n; i++) {
dp[i] = 1;
for (int j = 0; j < i; j++) {
if (a[j] < a[i]) dp[i] = (dp[i] + dp[j]) % md;
}
}
int sm = 0;
for (auto i : dp) sm = (sm + i) % md;
cout << sm;
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
356 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
356 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
0 ms |
348 KB |
Output is correct |
21 |
Correct |
53 ms |
600 KB |
Output is correct |
22 |
Correct |
53 ms |
716 KB |
Output is correct |
23 |
Correct |
50 ms |
600 KB |
Output is correct |
24 |
Correct |
58 ms |
716 KB |
Output is correct |
25 |
Correct |
53 ms |
604 KB |
Output is correct |
26 |
Correct |
43 ms |
604 KB |
Output is correct |
27 |
Correct |
58 ms |
640 KB |
Output is correct |
28 |
Correct |
40 ms |
604 KB |
Output is correct |
29 |
Correct |
39 ms |
604 KB |
Output is correct |
30 |
Correct |
218 ms |
54624 KB |
Output is correct |
31 |
Correct |
213 ms |
53596 KB |
Output is correct |
32 |
Correct |
260 ms |
54612 KB |
Output is correct |
33 |
Correct |
209 ms |
53004 KB |
Output is correct |
34 |
Correct |
208 ms |
53588 KB |
Output is correct |
35 |
Correct |
176 ms |
51148 KB |
Output is correct |
36 |
Correct |
169 ms |
52884 KB |
Output is correct |
37 |
Correct |
189 ms |
53608 KB |
Output is correct |
38 |
Correct |
198 ms |
51792 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2063 ms |
524116 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
356 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
0 ms |
348 KB |
Output is correct |
21 |
Correct |
53 ms |
600 KB |
Output is correct |
22 |
Correct |
53 ms |
716 KB |
Output is correct |
23 |
Correct |
50 ms |
600 KB |
Output is correct |
24 |
Correct |
58 ms |
716 KB |
Output is correct |
25 |
Correct |
53 ms |
604 KB |
Output is correct |
26 |
Correct |
43 ms |
604 KB |
Output is correct |
27 |
Correct |
58 ms |
640 KB |
Output is correct |
28 |
Correct |
40 ms |
604 KB |
Output is correct |
29 |
Correct |
39 ms |
604 KB |
Output is correct |
30 |
Correct |
218 ms |
54624 KB |
Output is correct |
31 |
Correct |
213 ms |
53596 KB |
Output is correct |
32 |
Correct |
260 ms |
54612 KB |
Output is correct |
33 |
Correct |
209 ms |
53004 KB |
Output is correct |
34 |
Correct |
208 ms |
53588 KB |
Output is correct |
35 |
Correct |
176 ms |
51148 KB |
Output is correct |
36 |
Correct |
169 ms |
52884 KB |
Output is correct |
37 |
Correct |
189 ms |
53608 KB |
Output is correct |
38 |
Correct |
198 ms |
51792 KB |
Output is correct |
39 |
Execution timed out |
2063 ms |
524116 KB |
Time limit exceeded |
40 |
Halted |
0 ms |
0 KB |
- |