답안 #433896

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
433896 2021-06-20T11:57:06 Z someone Boat (APIO16_boat) C++14
31 / 100
719 ms 524292 KB
#include <bits/stdc++.h>
using namespace std;

struct Val {
    int i, val;
};

const int M = 1 << 20, N = 2 * M, T = 542, MOD = 1e9 + 7;

int node[N];
int a[T], b[T];
vector<Val> p;

int getSum(int i) {
    if(i <= 1)
        return 0;
    int sum = getSum(i/2);
    if(i % 2 == 1)
        sum += node[i-1];
    return sum % MOD;
}

void add(int i, int val) {
    if(i == 0)
        return;
    node[i] = (node[i] + val) % MOD;
    add(i/2, val);
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int n;
    cin >> n;
    int sum = 0;
    for(int i = 0; i < n; i++) {
        cin >> a[i] >> b[i];
        sum += b[i] - a[i] + 1;
    }

    if(sum > M)
        return 0;

    for(int i = 0, x = 0; i < n; i++)
        for(int j = b[i]; j >= a[i]; j--, x++)
            p.push_back({x, j});

    sort(p.begin(), p.end(),
    [](Val v1, Val v2) {
        return v1.val < v2.val;
    });
    int pre = p[0].val;
    p[0].val = 1;
    int t = p.size();
    for(int i = 1; i < t; i++) {
        bool eq = (pre != p[i].val);
        pre = p[i].val;
        p[i].val = p[i-1].val + eq;
    }

    sort(p.begin(), p.end(),
    [](Val v1, Val v2) {
        return v1.i < v2.i;
    });

    sum = 0;
    for(int i = 0; i < t; i++) {
        int val = (getSum(p[i].val + M) + 1) % MOD;
        add(p[i].val + M, val);
        sum = (sum + val) % MOD;
    }
    cout << sum;
}
# 결과 실행 시간 메모리 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 332 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 1 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 332 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 1 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 284 ms 8696 KB Output is correct
22 Correct 269 ms 8592 KB Output is correct
23 Correct 250 ms 8640 KB Output is correct
24 Correct 279 ms 8636 KB Output is correct
25 Correct 280 ms 8640 KB Output is correct
26 Correct 287 ms 8640 KB Output is correct
27 Correct 316 ms 8640 KB Output is correct
28 Correct 297 ms 8640 KB Output is correct
29 Correct 300 ms 8640 KB Output is correct
30 Correct 310 ms 16160 KB Output is correct
31 Correct 335 ms 15656 KB Output is correct
32 Correct 288 ms 15896 KB Output is correct
33 Correct 324 ms 15556 KB Output is correct
34 Correct 300 ms 15604 KB Output is correct
35 Correct 254 ms 14888 KB Output is correct
36 Correct 302 ms 15500 KB Output is correct
37 Correct 259 ms 15616 KB Output is correct
38 Correct 255 ms 15112 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 719 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 332 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 1 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 284 ms 8696 KB Output is correct
22 Correct 269 ms 8592 KB Output is correct
23 Correct 250 ms 8640 KB Output is correct
24 Correct 279 ms 8636 KB Output is correct
25 Correct 280 ms 8640 KB Output is correct
26 Correct 287 ms 8640 KB Output is correct
27 Correct 316 ms 8640 KB Output is correct
28 Correct 297 ms 8640 KB Output is correct
29 Correct 300 ms 8640 KB Output is correct
30 Correct 310 ms 16160 KB Output is correct
31 Correct 335 ms 15656 KB Output is correct
32 Correct 288 ms 15896 KB Output is correct
33 Correct 324 ms 15556 KB Output is correct
34 Correct 300 ms 15604 KB Output is correct
35 Correct 254 ms 14888 KB Output is correct
36 Correct 302 ms 15500 KB Output is correct
37 Correct 259 ms 15616 KB Output is correct
38 Correct 255 ms 15112 KB Output is correct
39 Runtime error 719 ms 524292 KB Execution killed with signal 9
40 Halted 0 ms 0 KB -