# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
415853 |
2021-06-01T15:45:03 Z |
grt |
Boat (APIO16_boat) |
C++17 |
|
2000 ms |
200196 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;
dp2 = dp;
auto it = dp.end();
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;
}
dp2[j] = (dp2[j] + sum) % mod;
}
dp = dp2;
}
int ans = 0;
for(auto x : dp) ans = (ans + x.ND) % mod;
cout << ans - 1;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
332 KB |
Output is correct |
2 |
Correct |
7 ms |
340 KB |
Output is correct |
3 |
Correct |
8 ms |
340 KB |
Output is correct |
4 |
Correct |
6 ms |
344 KB |
Output is correct |
5 |
Correct |
8 ms |
376 KB |
Output is correct |
6 |
Correct |
5 ms |
324 KB |
Output is correct |
7 |
Correct |
5 ms |
332 KB |
Output is correct |
8 |
Incorrect |
5 ms |
332 KB |
Output isn't correct |
9 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
332 KB |
Output is correct |
2 |
Correct |
7 ms |
340 KB |
Output is correct |
3 |
Correct |
8 ms |
340 KB |
Output is correct |
4 |
Correct |
6 ms |
344 KB |
Output is correct |
5 |
Correct |
8 ms |
376 KB |
Output is correct |
6 |
Correct |
5 ms |
324 KB |
Output is correct |
7 |
Correct |
5 ms |
332 KB |
Output is correct |
8 |
Incorrect |
5 ms |
332 KB |
Output isn't correct |
9 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2102 ms |
200196 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
332 KB |
Output is correct |
2 |
Correct |
7 ms |
340 KB |
Output is correct |
3 |
Correct |
8 ms |
340 KB |
Output is correct |
4 |
Correct |
6 ms |
344 KB |
Output is correct |
5 |
Correct |
8 ms |
376 KB |
Output is correct |
6 |
Correct |
5 ms |
324 KB |
Output is correct |
7 |
Correct |
5 ms |
332 KB |
Output is correct |
8 |
Incorrect |
5 ms |
332 KB |
Output isn't correct |
9 |
Halted |
0 ms |
0 KB |
- |