# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
388956 |
2021-04-13T11:25:44 Z |
prvocislo |
Boat (APIO16_boat) |
C++17 |
|
1016 ms |
524292 KB |
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
typedef long long ll;
using namespace std;
const ll mod = 1e9 + 7;
void upd(ll& a, const ll& b)
{
a += b;
if (a >= mod)a -= mod;
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
int n;
cin >> n;
vector<int> a(n + 1), b(n + 1);
for (int i = 1; i <= n; i++) cin >> a[i] >> b[i];
vector<int> v;
for (int i = 0; i <= n; i++) for (int j = a[i]; j <= b[i]; j++) v.push_back(j);
sort(v.begin(), v.end());
v.erase(unique(v.begin(), v.end()), v.end());
vector<ll> dp(v.size(), 0);
dp[0] = 1;
for (int i = 1; i <= n; i++)
{
ll sum = 0;
for (int j = 0; j < v.size(); j++)
{
ll pv = dp[j];
if (a[i] <= v[j] && v[j] <= b[i])
{
upd(dp[j], sum);
}
upd(sum, pv);
}
}
ll ans = 0;
for (int j = 1; j < v.size(); j++) upd(ans, dp[j]);
cout << ans << "\n";
return 0;
}
Compilation message
boat.cpp: In function 'int main()':
boat.cpp:35:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
35 | for (int j = 0; j < v.size(); j++)
| ~~^~~~~~~~~~
boat.cpp:46:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
46 | for (int j = 1; j < v.size(); j++) upd(ans, dp[j]);
| ~~^~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
1 ms |
256 KB |
Output is correct |
7 |
Correct |
1 ms |
320 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
1 ms |
332 KB |
Output is correct |
11 |
Correct |
2 ms |
332 KB |
Output is correct |
12 |
Correct |
1 ms |
332 KB |
Output is correct |
13 |
Correct |
1 ms |
332 KB |
Output is correct |
14 |
Correct |
1 ms |
332 KB |
Output is correct |
15 |
Correct |
1 ms |
332 KB |
Output is correct |
16 |
Correct |
1 ms |
332 KB |
Output is correct |
17 |
Correct |
1 ms |
204 KB |
Output is correct |
18 |
Correct |
1 ms |
204 KB |
Output is correct |
19 |
Correct |
1 ms |
332 KB |
Output is correct |
20 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
1 ms |
256 KB |
Output is correct |
7 |
Correct |
1 ms |
320 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
1 ms |
332 KB |
Output is correct |
11 |
Correct |
2 ms |
332 KB |
Output is correct |
12 |
Correct |
1 ms |
332 KB |
Output is correct |
13 |
Correct |
1 ms |
332 KB |
Output is correct |
14 |
Correct |
1 ms |
332 KB |
Output is correct |
15 |
Correct |
1 ms |
332 KB |
Output is correct |
16 |
Correct |
1 ms |
332 KB |
Output is correct |
17 |
Correct |
1 ms |
204 KB |
Output is correct |
18 |
Correct |
1 ms |
204 KB |
Output is correct |
19 |
Correct |
1 ms |
332 KB |
Output is correct |
20 |
Correct |
1 ms |
204 KB |
Output is correct |
21 |
Correct |
47 ms |
4548 KB |
Output is correct |
22 |
Correct |
47 ms |
4548 KB |
Output is correct |
23 |
Correct |
43 ms |
4548 KB |
Output is correct |
24 |
Correct |
46 ms |
4548 KB |
Output is correct |
25 |
Correct |
48 ms |
4548 KB |
Output is correct |
26 |
Correct |
49 ms |
4548 KB |
Output is correct |
27 |
Correct |
50 ms |
4536 KB |
Output is correct |
28 |
Correct |
61 ms |
4548 KB |
Output is correct |
29 |
Correct |
50 ms |
4548 KB |
Output is correct |
30 |
Correct |
972 ms |
12080 KB |
Output is correct |
31 |
Correct |
979 ms |
11832 KB |
Output is correct |
32 |
Correct |
1016 ms |
12088 KB |
Output is correct |
33 |
Correct |
945 ms |
11696 KB |
Output is correct |
34 |
Correct |
961 ms |
11880 KB |
Output is correct |
35 |
Correct |
965 ms |
11352 KB |
Output is correct |
36 |
Correct |
964 ms |
11736 KB |
Output is correct |
37 |
Correct |
972 ms |
11856 KB |
Output is correct |
38 |
Correct |
1008 ms |
11484 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
709 ms |
524292 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
1 ms |
256 KB |
Output is correct |
7 |
Correct |
1 ms |
320 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
1 ms |
332 KB |
Output is correct |
11 |
Correct |
2 ms |
332 KB |
Output is correct |
12 |
Correct |
1 ms |
332 KB |
Output is correct |
13 |
Correct |
1 ms |
332 KB |
Output is correct |
14 |
Correct |
1 ms |
332 KB |
Output is correct |
15 |
Correct |
1 ms |
332 KB |
Output is correct |
16 |
Correct |
1 ms |
332 KB |
Output is correct |
17 |
Correct |
1 ms |
204 KB |
Output is correct |
18 |
Correct |
1 ms |
204 KB |
Output is correct |
19 |
Correct |
1 ms |
332 KB |
Output is correct |
20 |
Correct |
1 ms |
204 KB |
Output is correct |
21 |
Correct |
47 ms |
4548 KB |
Output is correct |
22 |
Correct |
47 ms |
4548 KB |
Output is correct |
23 |
Correct |
43 ms |
4548 KB |
Output is correct |
24 |
Correct |
46 ms |
4548 KB |
Output is correct |
25 |
Correct |
48 ms |
4548 KB |
Output is correct |
26 |
Correct |
49 ms |
4548 KB |
Output is correct |
27 |
Correct |
50 ms |
4536 KB |
Output is correct |
28 |
Correct |
61 ms |
4548 KB |
Output is correct |
29 |
Correct |
50 ms |
4548 KB |
Output is correct |
30 |
Correct |
972 ms |
12080 KB |
Output is correct |
31 |
Correct |
979 ms |
11832 KB |
Output is correct |
32 |
Correct |
1016 ms |
12088 KB |
Output is correct |
33 |
Correct |
945 ms |
11696 KB |
Output is correct |
34 |
Correct |
961 ms |
11880 KB |
Output is correct |
35 |
Correct |
965 ms |
11352 KB |
Output is correct |
36 |
Correct |
964 ms |
11736 KB |
Output is correct |
37 |
Correct |
972 ms |
11856 KB |
Output is correct |
38 |
Correct |
1008 ms |
11484 KB |
Output is correct |
39 |
Runtime error |
709 ms |
524292 KB |
Execution killed with signal 9 |
40 |
Halted |
0 ms |
0 KB |
- |