Submission #124209

#TimeUsernameProblemLanguageResultExecution timeMemory
124209AyaBenSaadBoat (APIO16_boat)C++14
9 / 100
2059 ms8392 KiB
#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)

boat.cpp: In function 'int main()':
boat.cpp:25:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
     ~~~~~^~~~~~~~~~
boat.cpp:27:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d %d", &a[i], &b[i]);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...