답안 #1027524

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1027524 2024-07-19T07:15:17 Z stdfloat Boat (APIO16_boat) C++17
9 / 100
2000 ms 233276 KB
#include <bits/stdc++.h>
using namespace std;

using ll = long long;

const int md = (int)1e9 + 7;

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);

    int n;
    cin >> n;

    vector<int> a(n), b(n);
    for (int i = 0; i < n; i++) cin >> a[i] >> b[i];

    map<int, int> m;
    for (int i = 0; i < n; i++) {
        // cout << "\ni " << i << '\n'; 

        int x = (m.empty() || a[i] <= (*m.begin()).first ? 0 : (*--m.lower_bound(a[i])).second);
        if (m.find(a[i]) == m.end()) m[a[i]] = x;
        for (int j = a[i] + 1; j <= b[i]; j++) {
            if (m.find(j) == m.end()) m[j] = m[j - 1];
        }
        int sm = 0;
        for (int j = a[i]; j <= b[i]; j++) {
            int y = m[j];

            sm = (sm + x + 1) % md;
            m[j] = (m[j] + sm) % md;

            // cout << "j " << j << ' ' << y << ' ' << m[j] << ' ' << x << '\n';

            x = y;
        }

        auto t = m.upper_bound(b[i]);
        while (t != m.end()) {
            m[(*t).first] = (m[(*t).first] + sm) % md; t++;
        }
    }

    cout << (*--m.end()).second << '\n';

    // int sm = 0;
    // for (auto i : m) sm = (sm + i.second) % md;

    // cout << sm << '\n';
}

/*sub1
vector<int> dp(n);
for (int i = 0; i < n; i++) {
    dp[i] = 1;
    for (int j = 0; j < i; j++) {
        if (a[j] < a[i]) dp[i] = (dp[i] + dp[j]) % md;
    }
}

int sm = 0;
for (auto i : dp) sm = (sm + i) % md;

cout << sm;
*/
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 348 KB Output is correct
2 Correct 2 ms 348 KB Output is correct
3 Correct 2 ms 348 KB Output is correct
4 Correct 2 ms 348 KB Output is correct
5 Correct 2 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 344 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 348 KB Output is correct
2 Correct 2 ms 348 KB Output is correct
3 Correct 2 ms 348 KB Output is correct
4 Correct 2 ms 348 KB Output is correct
5 Correct 2 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 344 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 224 ms 680 KB Output is correct
22 Correct 212 ms 604 KB Output is correct
23 Correct 208 ms 604 KB Output is correct
24 Correct 215 ms 604 KB Output is correct
25 Correct 218 ms 604 KB Output is correct
26 Correct 164 ms 596 KB Output is correct
27 Correct 189 ms 604 KB Output is correct
28 Correct 181 ms 616 KB Output is correct
29 Correct 185 ms 596 KB Output is correct
30 Correct 1801 ms 46676 KB Output is correct
31 Correct 1076 ms 45856 KB Output is correct
32 Correct 1333 ms 46796 KB Output is correct
33 Correct 1199 ms 45652 KB Output is correct
34 Correct 1390 ms 45892 KB Output is correct
35 Execution timed out 2097 ms 16768 KB Time limit exceeded
36 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2106 ms 233276 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 348 KB Output is correct
2 Correct 2 ms 348 KB Output is correct
3 Correct 2 ms 348 KB Output is correct
4 Correct 2 ms 348 KB Output is correct
5 Correct 2 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 344 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 224 ms 680 KB Output is correct
22 Correct 212 ms 604 KB Output is correct
23 Correct 208 ms 604 KB Output is correct
24 Correct 215 ms 604 KB Output is correct
25 Correct 218 ms 604 KB Output is correct
26 Correct 164 ms 596 KB Output is correct
27 Correct 189 ms 604 KB Output is correct
28 Correct 181 ms 616 KB Output is correct
29 Correct 185 ms 596 KB Output is correct
30 Correct 1801 ms 46676 KB Output is correct
31 Correct 1076 ms 45856 KB Output is correct
32 Correct 1333 ms 46796 KB Output is correct
33 Correct 1199 ms 45652 KB Output is correct
34 Correct 1390 ms 45892 KB Output is correct
35 Execution timed out 2097 ms 16768 KB Time limit exceeded
36 Halted 0 ms 0 KB -