# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
61103 | Eae02 | Boat (APIO16_boat) | C++14 | 2073 ms | 8840 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>
uint64_t PRIME = 1000000007;
std::vector<std::pair<uint64_t, uint64_t>> schools;
std::map<uint64_t, uint64_t> memo[500];
uint64_t count(int i, uint64_t min)
{
if (i >= schools.size())
return 1;
auto mIt = memo[i].find(min);
if (mIt != memo[i].end())
return mIt->second;
uint64_t c = count(i + 1, min);
for (uint64_t n = std::max(schools[i].first, min == 0 ? 0 : (min + 1)); n <= schools[i].second; n++)
{
c = (c + count(i + 1, n)) % PRIME;
}
memo[i].insert(std::make_pair(min, c));
return c;
}
int main()
{
int N;
std::cin >> N;
schools.resize(N);
for (int i = 0; i < N; i++)
{
std::cin >> schools[i].first;
std::cin >> schools[i].second;
}
std::cout << (count(0, 0) - 1) << std::endl;
}
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... |