답안 #947272

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
947272 2024-03-15T20:39:42 Z NValchanov Boat (APIO16_boat) C++17
9 / 100
2000 ms 359864 KB
#include<bits/stdc++.h>

#define endl '\n'
#define a first
#define b second

using namespace std;

typedef long long ll;

const int MAXN = 1e7 + 10;
const int MAXA = 1e6 + 10;
const int MOD = 1e9 + 7;

int n,cnt;
int a[MAXN];
int b[MAXN];
int dp[MAXN];
int pref[MAXN];
unordered_map <int,int> pos;

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

void fill_pos()
{
    set <int> st;

    for(int i = 1; i <= n; i++)
    {
        int from = a[i];
        int to = b[i];

        for(int j = from; j <= to; j++)
        {
            st.insert(j);
        }
    }

    int last = -1;

    for(int cur : st)
    {
        if(cur == last)
            continue;

        pos[cur] = ++cnt;
        last = cur;
    }
    /**
    for(auto x : pos)
    {
        cout << x.first << " " << x.second << endl;
    }
    */
}

void fill_dp()
{
    for(int i = 1; i <= n; i++)
    {
        int from = pos[a[i]];
        int to = pos[b[i]];
        for(int j = to; j >= from; j--)
        {
            dp[j] = (dp[j] + pref[j - 1] + 1 /** za nulata **/) % MOD;
        }
        for(int j = from; j <= cnt; j++)
        {
            pref[j] = (pref[j - 1] + dp[j]) % MOD;
        }
    }
}

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

    read();
    fill_pos();
    fill_dp();

    cout << pref[cnt] << endl;

	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4440 KB Output is correct
2 Correct 2 ms 4444 KB Output is correct
3 Correct 2 ms 4444 KB Output is correct
4 Correct 2 ms 4444 KB Output is correct
5 Correct 2 ms 4444 KB Output is correct
6 Correct 2 ms 4444 KB Output is correct
7 Correct 2 ms 4444 KB Output is correct
8 Correct 2 ms 4444 KB Output is correct
9 Correct 2 ms 4444 KB Output is correct
10 Correct 2 ms 4444 KB Output is correct
11 Correct 3 ms 4444 KB Output is correct
12 Correct 2 ms 4444 KB Output is correct
13 Correct 2 ms 4444 KB Output is correct
14 Correct 2 ms 4468 KB Output is correct
15 Correct 2 ms 4444 KB Output is correct
16 Correct 1 ms 4444 KB Output is correct
17 Correct 1 ms 4440 KB Output is correct
18 Correct 1 ms 4444 KB Output is correct
19 Correct 1 ms 4444 KB Output is correct
20 Correct 1 ms 4444 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4440 KB Output is correct
2 Correct 2 ms 4444 KB Output is correct
3 Correct 2 ms 4444 KB Output is correct
4 Correct 2 ms 4444 KB Output is correct
5 Correct 2 ms 4444 KB Output is correct
6 Correct 2 ms 4444 KB Output is correct
7 Correct 2 ms 4444 KB Output is correct
8 Correct 2 ms 4444 KB Output is correct
9 Correct 2 ms 4444 KB Output is correct
10 Correct 2 ms 4444 KB Output is correct
11 Correct 3 ms 4444 KB Output is correct
12 Correct 2 ms 4444 KB Output is correct
13 Correct 2 ms 4444 KB Output is correct
14 Correct 2 ms 4468 KB Output is correct
15 Correct 2 ms 4444 KB Output is correct
16 Correct 1 ms 4444 KB Output is correct
17 Correct 1 ms 4440 KB Output is correct
18 Correct 1 ms 4444 KB Output is correct
19 Correct 1 ms 4444 KB Output is correct
20 Correct 1 ms 4444 KB Output is correct
21 Correct 28 ms 4956 KB Output is correct
22 Correct 28 ms 5208 KB Output is correct
23 Correct 28 ms 4956 KB Output is correct
24 Correct 29 ms 4956 KB Output is correct
25 Correct 29 ms 4956 KB Output is correct
26 Correct 27 ms 4696 KB Output is correct
27 Correct 28 ms 4700 KB Output is correct
28 Correct 28 ms 4700 KB Output is correct
29 Correct 27 ms 4696 KB Output is correct
30 Execution timed out 2039 ms 100552 KB Time limit exceeded
31 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2017 ms 359864 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4440 KB Output is correct
2 Correct 2 ms 4444 KB Output is correct
3 Correct 2 ms 4444 KB Output is correct
4 Correct 2 ms 4444 KB Output is correct
5 Correct 2 ms 4444 KB Output is correct
6 Correct 2 ms 4444 KB Output is correct
7 Correct 2 ms 4444 KB Output is correct
8 Correct 2 ms 4444 KB Output is correct
9 Correct 2 ms 4444 KB Output is correct
10 Correct 2 ms 4444 KB Output is correct
11 Correct 3 ms 4444 KB Output is correct
12 Correct 2 ms 4444 KB Output is correct
13 Correct 2 ms 4444 KB Output is correct
14 Correct 2 ms 4468 KB Output is correct
15 Correct 2 ms 4444 KB Output is correct
16 Correct 1 ms 4444 KB Output is correct
17 Correct 1 ms 4440 KB Output is correct
18 Correct 1 ms 4444 KB Output is correct
19 Correct 1 ms 4444 KB Output is correct
20 Correct 1 ms 4444 KB Output is correct
21 Correct 28 ms 4956 KB Output is correct
22 Correct 28 ms 5208 KB Output is correct
23 Correct 28 ms 4956 KB Output is correct
24 Correct 29 ms 4956 KB Output is correct
25 Correct 29 ms 4956 KB Output is correct
26 Correct 27 ms 4696 KB Output is correct
27 Correct 28 ms 4700 KB Output is correct
28 Correct 28 ms 4700 KB Output is correct
29 Correct 27 ms 4696 KB Output is correct
30 Execution timed out 2039 ms 100552 KB Time limit exceeded
31 Halted 0 ms 0 KB -