답안 #923233

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
923233 2024-02-07T02:36:32 Z quanlt206 Boat (APIO16_boat) C++17
31 / 100
84 ms 18116 KB
#include<bits/stdc++.h>
#define X first
#define Y second
#define all(x) begin(x), end(x)
#define FOR(i, a, b) for(int i = (a); i <= (b); i++)
#define FORD(i, b, a) for(int i = (b); i >= (a); i--)
#define REP(i, a, b) for (int i = (a); i < (b); i++)
#define mxx max_element
#define mnn min_element
#define SQR(x) (1LL * (x) * (x))
#define MASK(i) (1LL << (i))
#define Point Vector
#define left Left
#define right Right
#define div Div

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
typedef pair<db, db> pdb;
typedef pair<ld, ld> pld;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef pair<ll, ll> pll;
typedef pair<ll, pll> plll;
typedef pair<ll, int> pli;
typedef pair<ll, pii> plii;

template<class A, class B>
    bool maximize(A& x, B y) {
        if (x < y) return x = y, true; else return false;
    }
template<class A, class B>
    bool minimize(A& x, B y) {
        if (x > y) return x = y, true; else return false;
    }
/* END OF TEMPLATE */

const int N = 5e2 + 7;
const int mod = 1e9 + 7;
int n, a[N], b[N];

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

namespace sub12 {
    const int N = 1e6 + 5008;
    struct BIT {
        int bit[N], n;
        BIT() {
            n = 0;
            REP(i, 0, N) bit[i] = 0;
        }
        void update(int p, int u) {
            for (; p <= n; p+=p & -p) bit[p] = (bit[p] + u) % mod;
        }
        int Get(int p) {
            int res = 0;
            for (; p > 0; p-=p & -p) res = (res + bit[p]) % mod;
            return res;
        }
    } bit;
    int f[N], pre[N];
    vector<int> E;
    void buildE() {
        FOR(i, 1, n)
            FOR(j, a[i], b[i]) E.push_back(j);
        sort(all(E));
        vector<int> new_E;
        for (auto x : E)
            if (new_E.empty() || new_E.back() != x) new_E.push_back(x);
        E = new_E;
    }
    void Process() {
        buildE();
        bit.n = (int)E.size();
        int m = E.size();
        FOR(i, 1, n) {
            a[i] = lower_bound(all(E), a[i]) - E.begin() + 1;
            b[i] = lower_bound(all(E), b[i]) - E.begin() + 1;
            FOR(j, a[i], b[i]) {
                f[j] = bit.Get(j - 1) + 1;
            }
            FOR(j, a[i], b[i]) bit.update(j, f[j]);
        }
        cout<<bit.Get(m);
    }
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin>>n;
    ll sum = 0;
    FOR(i, 1, n) {
        cin>>a[i]>>b[i];
        sum+=b[i] - a[i];
    }
    if (sum <= 1e6) {
        sub12::Process();
        return 0;
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 7772 KB Output is correct
2 Correct 2 ms 7772 KB Output is correct
3 Correct 2 ms 7772 KB Output is correct
4 Correct 2 ms 7772 KB Output is correct
5 Correct 2 ms 7772 KB Output is correct
6 Correct 2 ms 7772 KB Output is correct
7 Correct 2 ms 7772 KB Output is correct
8 Correct 1 ms 7772 KB Output is correct
9 Correct 2 ms 7772 KB Output is correct
10 Correct 2 ms 7772 KB Output is correct
11 Correct 2 ms 7772 KB Output is correct
12 Correct 2 ms 7772 KB Output is correct
13 Correct 2 ms 7772 KB Output is correct
14 Correct 1 ms 7772 KB Output is correct
15 Correct 2 ms 7772 KB Output is correct
16 Correct 2 ms 7772 KB Output is correct
17 Correct 2 ms 7772 KB Output is correct
18 Correct 2 ms 7772 KB Output is correct
19 Correct 2 ms 7772 KB Output is correct
20 Correct 2 ms 7772 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 7772 KB Output is correct
2 Correct 2 ms 7772 KB Output is correct
3 Correct 2 ms 7772 KB Output is correct
4 Correct 2 ms 7772 KB Output is correct
5 Correct 2 ms 7772 KB Output is correct
6 Correct 2 ms 7772 KB Output is correct
7 Correct 2 ms 7772 KB Output is correct
8 Correct 1 ms 7772 KB Output is correct
9 Correct 2 ms 7772 KB Output is correct
10 Correct 2 ms 7772 KB Output is correct
11 Correct 2 ms 7772 KB Output is correct
12 Correct 2 ms 7772 KB Output is correct
13 Correct 2 ms 7772 KB Output is correct
14 Correct 1 ms 7772 KB Output is correct
15 Correct 2 ms 7772 KB Output is correct
16 Correct 2 ms 7772 KB Output is correct
17 Correct 2 ms 7772 KB Output is correct
18 Correct 2 ms 7772 KB Output is correct
19 Correct 2 ms 7772 KB Output is correct
20 Correct 2 ms 7772 KB Output is correct
21 Correct 50 ms 11560 KB Output is correct
22 Correct 51 ms 11984 KB Output is correct
23 Correct 47 ms 11472 KB Output is correct
24 Correct 57 ms 11376 KB Output is correct
25 Correct 52 ms 11988 KB Output is correct
26 Correct 52 ms 11984 KB Output is correct
27 Correct 53 ms 11916 KB Output is correct
28 Correct 52 ms 11732 KB Output is correct
29 Correct 53 ms 11988 KB Output is correct
30 Correct 70 ms 16304 KB Output is correct
31 Correct 84 ms 17668 KB Output is correct
32 Correct 70 ms 17104 KB Output is correct
33 Correct 68 ms 18116 KB Output is correct
34 Correct 69 ms 16804 KB Output is correct
35 Correct 82 ms 16576 KB Output is correct
36 Correct 81 ms 17988 KB Output is correct
37 Correct 80 ms 15804 KB Output is correct
38 Correct 77 ms 16824 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 5724 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 7772 KB Output is correct
2 Correct 2 ms 7772 KB Output is correct
3 Correct 2 ms 7772 KB Output is correct
4 Correct 2 ms 7772 KB Output is correct
5 Correct 2 ms 7772 KB Output is correct
6 Correct 2 ms 7772 KB Output is correct
7 Correct 2 ms 7772 KB Output is correct
8 Correct 1 ms 7772 KB Output is correct
9 Correct 2 ms 7772 KB Output is correct
10 Correct 2 ms 7772 KB Output is correct
11 Correct 2 ms 7772 KB Output is correct
12 Correct 2 ms 7772 KB Output is correct
13 Correct 2 ms 7772 KB Output is correct
14 Correct 1 ms 7772 KB Output is correct
15 Correct 2 ms 7772 KB Output is correct
16 Correct 2 ms 7772 KB Output is correct
17 Correct 2 ms 7772 KB Output is correct
18 Correct 2 ms 7772 KB Output is correct
19 Correct 2 ms 7772 KB Output is correct
20 Correct 2 ms 7772 KB Output is correct
21 Correct 50 ms 11560 KB Output is correct
22 Correct 51 ms 11984 KB Output is correct
23 Correct 47 ms 11472 KB Output is correct
24 Correct 57 ms 11376 KB Output is correct
25 Correct 52 ms 11988 KB Output is correct
26 Correct 52 ms 11984 KB Output is correct
27 Correct 53 ms 11916 KB Output is correct
28 Correct 52 ms 11732 KB Output is correct
29 Correct 53 ms 11988 KB Output is correct
30 Correct 70 ms 16304 KB Output is correct
31 Correct 84 ms 17668 KB Output is correct
32 Correct 70 ms 17104 KB Output is correct
33 Correct 68 ms 18116 KB Output is correct
34 Correct 69 ms 16804 KB Output is correct
35 Correct 82 ms 16576 KB Output is correct
36 Correct 81 ms 17988 KB Output is correct
37 Correct 80 ms 15804 KB Output is correct
38 Correct 77 ms 16824 KB Output is correct
39 Incorrect 2 ms 5724 KB Output isn't correct
40 Halted 0 ms 0 KB -