# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
415857 |
2021-06-01T15:48:13 Z |
grt |
Boat (APIO16_boat) |
C++17 |
|
2000 ms |
524292 KB |
#include <bits/stdc++.h>
#define ST first
#define ND second
#define PB push_back
using namespace std;
using ll = long long;
using pi = pair<int,int>;
using vi = vector<int>;
const int nax = 500 + 10, mod = 1e9 + 7;
int n, mx;
map<int, int>dp, dp2;
int a[nax], b[nax];
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> n;
for(int i = 1; i <= n; ++i) {
cin >> a[i] >> b[i];
}
dp[0] = 1;
for(int i = 1; i <= n; ++i) {
int sum = 0;
for(auto x : dp) sum = (sum + x.ND) % mod;
auto it = dp.end();
vector<pi>value = {};
for(int j = b[i]; j >= a[i]; --j) {
while(it != dp.begin() && (*prev(it)).ST >= j) {
it = prev(it);
sum = (sum - (*it).ND) % mod;
}
value.emplace_back(j, sum);
}
for(auto x : value) {
dp[x.ST] = (dp[x.ST] + x.ND) % mod;
}
}
int ans = 0;
for(auto x : dp) ans = (ans + x.ND) % mod;
ans--;
if(ans < 0) ans += mod;
cout << ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
332 KB |
Output is correct |
2 |
Correct |
3 ms |
332 KB |
Output is correct |
3 |
Correct |
3 ms |
332 KB |
Output is correct |
4 |
Correct |
3 ms |
332 KB |
Output is correct |
5 |
Correct |
3 ms |
332 KB |
Output is correct |
6 |
Correct |
2 ms |
332 KB |
Output is correct |
7 |
Correct |
2 ms |
332 KB |
Output is correct |
8 |
Correct |
2 ms |
332 KB |
Output is correct |
9 |
Correct |
3 ms |
332 KB |
Output is correct |
10 |
Correct |
2 ms |
332 KB |
Output is correct |
11 |
Correct |
2 ms |
332 KB |
Output is correct |
12 |
Correct |
2 ms |
332 KB |
Output is correct |
13 |
Correct |
2 ms |
332 KB |
Output is correct |
14 |
Correct |
2 ms |
332 KB |
Output is correct |
15 |
Correct |
2 ms |
332 KB |
Output is correct |
16 |
Correct |
2 ms |
204 KB |
Output is correct |
17 |
Correct |
2 ms |
204 KB |
Output is correct |
18 |
Correct |
2 ms |
204 KB |
Output is correct |
19 |
Correct |
2 ms |
204 KB |
Output is correct |
20 |
Correct |
2 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
332 KB |
Output is correct |
2 |
Correct |
3 ms |
332 KB |
Output is correct |
3 |
Correct |
3 ms |
332 KB |
Output is correct |
4 |
Correct |
3 ms |
332 KB |
Output is correct |
5 |
Correct |
3 ms |
332 KB |
Output is correct |
6 |
Correct |
2 ms |
332 KB |
Output is correct |
7 |
Correct |
2 ms |
332 KB |
Output is correct |
8 |
Correct |
2 ms |
332 KB |
Output is correct |
9 |
Correct |
3 ms |
332 KB |
Output is correct |
10 |
Correct |
2 ms |
332 KB |
Output is correct |
11 |
Correct |
2 ms |
332 KB |
Output is correct |
12 |
Correct |
2 ms |
332 KB |
Output is correct |
13 |
Correct |
2 ms |
332 KB |
Output is correct |
14 |
Correct |
2 ms |
332 KB |
Output is correct |
15 |
Correct |
2 ms |
332 KB |
Output is correct |
16 |
Correct |
2 ms |
204 KB |
Output is correct |
17 |
Correct |
2 ms |
204 KB |
Output is correct |
18 |
Correct |
2 ms |
204 KB |
Output is correct |
19 |
Correct |
2 ms |
204 KB |
Output is correct |
20 |
Correct |
2 ms |
204 KB |
Output is correct |
21 |
Correct |
138 ms |
648 KB |
Output is correct |
22 |
Correct |
137 ms |
652 KB |
Output is correct |
23 |
Correct |
133 ms |
672 KB |
Output is correct |
24 |
Correct |
163 ms |
664 KB |
Output is correct |
25 |
Correct |
147 ms |
648 KB |
Output is correct |
26 |
Correct |
123 ms |
464 KB |
Output is correct |
27 |
Correct |
127 ms |
484 KB |
Output is correct |
28 |
Correct |
134 ms |
508 KB |
Output is correct |
29 |
Correct |
131 ms |
508 KB |
Output is correct |
30 |
Execution timed out |
2067 ms |
21828 KB |
Time limit exceeded |
31 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
535 ms |
524292 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
332 KB |
Output is correct |
2 |
Correct |
3 ms |
332 KB |
Output is correct |
3 |
Correct |
3 ms |
332 KB |
Output is correct |
4 |
Correct |
3 ms |
332 KB |
Output is correct |
5 |
Correct |
3 ms |
332 KB |
Output is correct |
6 |
Correct |
2 ms |
332 KB |
Output is correct |
7 |
Correct |
2 ms |
332 KB |
Output is correct |
8 |
Correct |
2 ms |
332 KB |
Output is correct |
9 |
Correct |
3 ms |
332 KB |
Output is correct |
10 |
Correct |
2 ms |
332 KB |
Output is correct |
11 |
Correct |
2 ms |
332 KB |
Output is correct |
12 |
Correct |
2 ms |
332 KB |
Output is correct |
13 |
Correct |
2 ms |
332 KB |
Output is correct |
14 |
Correct |
2 ms |
332 KB |
Output is correct |
15 |
Correct |
2 ms |
332 KB |
Output is correct |
16 |
Correct |
2 ms |
204 KB |
Output is correct |
17 |
Correct |
2 ms |
204 KB |
Output is correct |
18 |
Correct |
2 ms |
204 KB |
Output is correct |
19 |
Correct |
2 ms |
204 KB |
Output is correct |
20 |
Correct |
2 ms |
204 KB |
Output is correct |
21 |
Correct |
138 ms |
648 KB |
Output is correct |
22 |
Correct |
137 ms |
652 KB |
Output is correct |
23 |
Correct |
133 ms |
672 KB |
Output is correct |
24 |
Correct |
163 ms |
664 KB |
Output is correct |
25 |
Correct |
147 ms |
648 KB |
Output is correct |
26 |
Correct |
123 ms |
464 KB |
Output is correct |
27 |
Correct |
127 ms |
484 KB |
Output is correct |
28 |
Correct |
134 ms |
508 KB |
Output is correct |
29 |
Correct |
131 ms |
508 KB |
Output is correct |
30 |
Execution timed out |
2067 ms |
21828 KB |
Time limit exceeded |
31 |
Halted |
0 ms |
0 KB |
- |