답안 #480637

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
480637 2021-10-17T13:14:33 Z Karliver Boat (APIO16_boat) C++17
31 / 100
1040 ms 524292 KB
    
#include <bits/stdc++.h>

#define FIXED_FLOAT(x)  std::fixed <<std::setprecision(20) << (x)
#define all(v) (v).begin(), (v).end()
using namespace  std;
#define forn(i,n) for (int i = 0; i < (n); ++i)
#define rforn(i, n) for(int i = (n) - 1;i >= 0;--i)
#define sz(x) (int)x.size()

using ll = long long;
int mod = (ll)1e9 + 7;
#define PI acos(-1)
typedef pair<int, int> pairs;

const int INF = 1e9 + 1;
const int N = 2e5 + 100;
const double eps = 1e-7;

template <class T> using V = vector<T>;  
template <class T> using VV = V<V<T>>;  
template<class T, size_t SZ> using AR = array<T, SZ>;
template<class T> using PR = pair<T, T>;
template <typename XPAX>
bool ckma(XPAX &x, XPAX y) {
    return (x < y ? x = y, 1 : 0);
}
template <typename XPAX>
bool ckmi(XPAX &x, XPAX y) {
    return (x > y ? x = y, 1 : 0);
}
int A[N], B[N];

void add(ll &x, ll y) {
    x += y;
    if(x >= mod)x -= mod;
}
void solve() {


    int n;
    cin >> n;

    forn(i, n) cin >> A[i] >> B[i];

    VV<ll> dp(n);
    forn(i, n) dp[i].push_back(0);
    

    

    for(int i = 0;i < n;++i) {
        for(int x = A[i];x <= B[i];++x) {
            ll now = 1;
            for(int j = 0;j < i;++j) {
                if(A[j] < x)
                    add(now, dp[j][min(B[j] - A[j] + 1, x - A[j])]);
            }
            dp[i].push_back((dp[i].back() + now) % mod);
        }
    }

    ll ret = 0;

    forn(i, n) add(ret, dp[i].back());

    cout << ret << '\n';


}
void test_case() {
    int t;
    cin >> t;
    forn(p, t) {

        //cout << "Case #" << p + 1 << ": ";
        solve();
    }
}
int main() {

    ios::sync_with_stdio(false);
    cin.tie(0);

    solve();

}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 2 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 2 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 640 ms 8824 KB Output is correct
22 Correct 596 ms 8848 KB Output is correct
23 Correct 608 ms 8404 KB Output is correct
24 Correct 618 ms 9160 KB Output is correct
25 Correct 591 ms 9108 KB Output is correct
26 Correct 824 ms 8328 KB Output is correct
27 Correct 848 ms 8484 KB Output is correct
28 Correct 856 ms 8456 KB Output is correct
29 Correct 848 ms 8344 KB Output is correct
30 Correct 1040 ms 9920 KB Output is correct
31 Correct 923 ms 9980 KB Output is correct
32 Correct 1006 ms 10076 KB Output is correct
33 Correct 920 ms 9820 KB Output is correct
34 Correct 917 ms 9820 KB Output is correct
35 Correct 482 ms 9272 KB Output is correct
36 Correct 647 ms 9680 KB Output is correct
37 Correct 575 ms 9680 KB Output is correct
38 Correct 590 ms 9688 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 627 ms 524292 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 2 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 640 ms 8824 KB Output is correct
22 Correct 596 ms 8848 KB Output is correct
23 Correct 608 ms 8404 KB Output is correct
24 Correct 618 ms 9160 KB Output is correct
25 Correct 591 ms 9108 KB Output is correct
26 Correct 824 ms 8328 KB Output is correct
27 Correct 848 ms 8484 KB Output is correct
28 Correct 856 ms 8456 KB Output is correct
29 Correct 848 ms 8344 KB Output is correct
30 Correct 1040 ms 9920 KB Output is correct
31 Correct 923 ms 9980 KB Output is correct
32 Correct 1006 ms 10076 KB Output is correct
33 Correct 920 ms 9820 KB Output is correct
34 Correct 917 ms 9820 KB Output is correct
35 Correct 482 ms 9272 KB Output is correct
36 Correct 647 ms 9680 KB Output is correct
37 Correct 575 ms 9680 KB Output is correct
38 Correct 590 ms 9688 KB Output is correct
39 Runtime error 627 ms 524292 KB Execution killed with signal 9
40 Halted 0 ms 0 KB -