답안 #1005775

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1005775 2024-06-23T04:27:35 Z omsincoconut Boat (APIO16_boat) C++17
9 / 100
147 ms 8272 KB
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

const ll MOD = 1e9+7, MAXN = 505;

ll n, a[MAXN], b[MAXN];
vector<ll> dis;

ll disz;
ll dp[MAXN][2*MAXN] = {0}, qdp[MAXN][2*MAXN];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> n;
    for (ll i = 1; i <= n; i++) cin >> a[i] >> b[i];
    for (ll i = 1; i <= n; i++) dis.push_back(a[i]), dis.push_back(b[i]);
    dis.push_back(0);
    sort(dis.begin(), dis.end());
    dis.resize(unique(dis.begin(), dis.end()) - dis.begin());
    disz = dis.size();

    for (ll i = 1; i <= n; i++) {
        ll beg = lower_bound(dis.begin(), dis.end(), a[i]) - dis.begin();
        ll lst = lower_bound(dis.begin(), dis.end(), b[i]) - dis.begin();

        for (ll j = beg; j < lst; j++) {
            ll df = dis[j+1] - dis[j];
            dp[i][j] = df; // start sequence here
            for (ll k = 1; k < i; k++) {
                dp[i][j] += df*qdp[k][j-1];
                dp[i][j] %= MOD;
            }
        }

        {
            // choose b[i]
            dp[i][lst] = 1;
            for (ll k = 1; k < i; k++) {
                dp[i][lst] += qdp[k][lst-1];
                dp[i][lst] %= MOD;
            }
        }

        qdp[i][0] = 0;
        for (ll j = 1; j < disz; j++) qdp[i][j] = (qdp[i][j-1] + dp[i][j])%MOD;
    }

    ll ans = 0;
    for (ll i = 1; i <= n; i++) for (ll j = 0; j < disz; j++) {
        ans += dp[i][j];
        ans %= MOD;
    }

    cout << ans;

    /*cout << "\n";
    for (ll i = 1; i <= n; i++) {
        for (ll j = 0; j < disz; j++) cout << dp[i][j] << " ";
        cout << "\n";
    }*/

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 7516 KB Output is correct
2 Correct 3 ms 7516 KB Output is correct
3 Correct 4 ms 7516 KB Output is correct
4 Correct 4 ms 7516 KB Output is correct
5 Correct 4 ms 7516 KB Output is correct
6 Correct 3 ms 7644 KB Output is correct
7 Correct 4 ms 7516 KB Output is correct
8 Correct 4 ms 7516 KB Output is correct
9 Correct 4 ms 7516 KB Output is correct
10 Correct 3 ms 7516 KB Output is correct
11 Correct 4 ms 7516 KB Output is correct
12 Correct 4 ms 7516 KB Output is correct
13 Correct 4 ms 7516 KB Output is correct
14 Correct 4 ms 7516 KB Output is correct
15 Correct 4 ms 7516 KB Output is correct
16 Correct 2 ms 7516 KB Output is correct
17 Correct 2 ms 7516 KB Output is correct
18 Correct 2 ms 7516 KB Output is correct
19 Correct 2 ms 7516 KB Output is correct
20 Correct 2 ms 7516 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 7516 KB Output is correct
2 Correct 3 ms 7516 KB Output is correct
3 Correct 4 ms 7516 KB Output is correct
4 Correct 4 ms 7516 KB Output is correct
5 Correct 4 ms 7516 KB Output is correct
6 Correct 3 ms 7644 KB Output is correct
7 Correct 4 ms 7516 KB Output is correct
8 Correct 4 ms 7516 KB Output is correct
9 Correct 4 ms 7516 KB Output is correct
10 Correct 3 ms 7516 KB Output is correct
11 Correct 4 ms 7516 KB Output is correct
12 Correct 4 ms 7516 KB Output is correct
13 Correct 4 ms 7516 KB Output is correct
14 Correct 4 ms 7516 KB Output is correct
15 Correct 4 ms 7516 KB Output is correct
16 Correct 2 ms 7516 KB Output is correct
17 Correct 2 ms 7516 KB Output is correct
18 Correct 2 ms 7516 KB Output is correct
19 Correct 2 ms 7516 KB Output is correct
20 Correct 2 ms 7516 KB Output is correct
21 Incorrect 147 ms 8272 KB Output isn't correct
22 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 6748 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 7516 KB Output is correct
2 Correct 3 ms 7516 KB Output is correct
3 Correct 4 ms 7516 KB Output is correct
4 Correct 4 ms 7516 KB Output is correct
5 Correct 4 ms 7516 KB Output is correct
6 Correct 3 ms 7644 KB Output is correct
7 Correct 4 ms 7516 KB Output is correct
8 Correct 4 ms 7516 KB Output is correct
9 Correct 4 ms 7516 KB Output is correct
10 Correct 3 ms 7516 KB Output is correct
11 Correct 4 ms 7516 KB Output is correct
12 Correct 4 ms 7516 KB Output is correct
13 Correct 4 ms 7516 KB Output is correct
14 Correct 4 ms 7516 KB Output is correct
15 Correct 4 ms 7516 KB Output is correct
16 Correct 2 ms 7516 KB Output is correct
17 Correct 2 ms 7516 KB Output is correct
18 Correct 2 ms 7516 KB Output is correct
19 Correct 2 ms 7516 KB Output is correct
20 Correct 2 ms 7516 KB Output is correct
21 Incorrect 147 ms 8272 KB Output isn't correct
22 Halted 0 ms 0 KB -