# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
433852 | JeanBombeur | Boat (APIO16_boat) | C++17 | 1454 ms | 524292 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 <iostream>
#include <cstdio>
#include <vector>
#define int long long
using namespace std;
// <|°_°|>
const int MOD = (1000 * 1000 * 1000 + 7);
const int MAX_GROUPES = (501);
vector <int> DP[MAX_GROUPES];
pair <int, int> Bornes[MAX_GROUPES];
int nbGroupes;
void Read() {
scanf("%lld", &nbGroupes);
nbGroupes ++;
for (int i = 1; i < nbGroupes; i ++)
{
scanf("%lld %lld", &Bornes[i].first, &Bornes[i].second);
for (int j = Bornes[i].first; j <= Bornes[i].second; j ++)
{
DP[i].push_back(0);
}
}
DP[0].push_back(1);
return;
}
void Solve() {
int sum = -1;
for (int i = 0; i < nbGroupes; i ++)
{
int sz = DP[i].size();
for (int k = 0; k < sz; k ++)
{
DP[i][k] %= MOD;
sum += DP[i][k];
if (k < sz - 1)
DP[i][k + 1] += DP[i][k];
for (int j = i + 1; j < nbGroupes; j ++)
{
if (Bornes[j].second > Bornes[i].first + k)
{
DP[j][max(0LL, Bornes[i].first + k + 1 - Bornes[j].first)] += DP[i][k];
}
}
}
}
printf("%lld\n", sum % MOD);
return;
}
signed main() {
Read();
Solve();
return 0;
}
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... |