# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
124209 | AyaBenSaad | Boat (APIO16_boat) | C++14 | 2059 ms | 8392 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int M = 5e2 + 2;
const int N = 1e2 + 6;
int n, a[M], b[M];
set <int> s;
vector <int> v;
map <pair <int, int>, int> dp;
int solve (int id, int last) {
if (id >= n) return (last != 0 ? 1 : 0);
int &ret = dp[{id,last}];
if (ret != 0) return ret;
ret = solve(id+1, last);
for (int i = max (a[id], last+1); i <= b[id]; i++) {
ret = (1ll*ret + 1ll*solve (id+1, i)) % MOD;
}
return ret;
}
int main () {
scanf("%d", &n);
for (int i = 0; i < n; i++) {
scanf("%d %d", &a[i], &b[i]);
s.insert (a[i]);
s.insert (b[i]);
}
for (int i : s) {
v.push_back(i);
}
printf("%d\n", solve (0, 0));
}
//1 2
//2 3
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |