답안 #978333

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
978333 2024-05-09T06:26:05 Z Amr Boat (APIO16_boat) C++17
31 / 100
2000 ms 189796 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define S second
#define F first
#define all(x) (x).begin(),(x).end()
#define sz size()
#define Yes cout << "YES" << endl
#define No cout << "NO" << endl
#define pb(x) push_back(x);
#define endl '\n'
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const int N=502;
ll INF=INT_MAX,mod=1e9+7;
int TT=1;
ll power(ll x, unsigned int y)
{
    ll res = 1;
    x = x; // % mod;
    if (x == 0) return 0;
    while (y > 0)
    {
        if (y & 1) res = (res*x)  ; // % mod;
        y = y>>1;
        x = (x*x) ; // % mod;
    }
    return res;
}
ll k = 1;
const int M = 1e6+2, logn = 32;
ll seg[M*logn+M];
ll L[M*logn+M], R[M*logn+M];
ll a[N], b[N];
ll n,siz = 1;
void upd(ll node, ll in , ll val , ll lx = 0, ll rx = siz)
{
    if(rx-lx==1) {seg[node] += val; return;}
    ll mid = (lx+rx)/2;
    if(L[node]==0) L[node] = k++, R[node] = k++;
    if(in<mid) upd(L[node],in,val,lx,mid);
    else upd(R[node],in,val,mid,rx);
    seg[node] = (seg[L[node]]+seg[R[node]])%mod;
}
ll get(ll node, ll l , ll r, ll lx = 0, ll rx = siz)
{
    if(lx>=r||rx<=l) return 0;
    if(lx>=l&&rx<=r) return seg[node];
    ll mid = (lx+rx)/2;
    if(L[node]==0) L[node] = k++, R[node] = k++;
    return (get(L[node],l,r,lx,mid) + get(R[node],l,r,mid,rx))%mod;
}
void solve()
{
    cin >> n;
    siz = 1e9+1;
    for(int i = 1; i <= n; i++) cin >> a[i] >> b[i];
    upd(0,0,1);
    for(int i = 1; i <= n; i++)
    {
        for(int j = b[i]; j >= a[i]; j--)
        {
            ll ans = get(0,0,j);
            upd(0,j,ans);
        }
    }
    cout << (get(0,1,siz)+mod)%mod << endl;
}
int main(){
    //freopen("friday.in","r",stdin);
    //freopen("friday.out","w",stdout);
    fast;
    while(TT--)
        solve();

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2648 KB Output is correct
2 Correct 1 ms 860 KB Output is correct
3 Correct 1 ms 980 KB Output is correct
4 Correct 2 ms 860 KB Output is correct
5 Correct 1 ms 2652 KB Output is correct
6 Correct 1 ms 860 KB Output is correct
7 Correct 1 ms 1112 KB Output is correct
8 Correct 1 ms 2648 KB Output is correct
9 Correct 1 ms 860 KB Output is correct
10 Correct 1 ms 860 KB Output is correct
11 Correct 1 ms 860 KB Output is correct
12 Correct 1 ms 860 KB Output is correct
13 Correct 1 ms 860 KB Output is correct
14 Correct 1 ms 2652 KB Output is correct
15 Correct 1 ms 856 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 1 ms 604 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 604 KB Output is correct
20 Correct 1 ms 604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2648 KB Output is correct
2 Correct 1 ms 860 KB Output is correct
3 Correct 1 ms 980 KB Output is correct
4 Correct 2 ms 860 KB Output is correct
5 Correct 1 ms 2652 KB Output is correct
6 Correct 1 ms 860 KB Output is correct
7 Correct 1 ms 1112 KB Output is correct
8 Correct 1 ms 2648 KB Output is correct
9 Correct 1 ms 860 KB Output is correct
10 Correct 1 ms 860 KB Output is correct
11 Correct 1 ms 860 KB Output is correct
12 Correct 1 ms 860 KB Output is correct
13 Correct 1 ms 860 KB Output is correct
14 Correct 1 ms 2652 KB Output is correct
15 Correct 1 ms 856 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 1 ms 604 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 604 KB Output is correct
20 Correct 1 ms 604 KB Output is correct
21 Correct 394 ms 716 KB Output is correct
22 Correct 396 ms 2904 KB Output is correct
23 Correct 368 ms 716 KB Output is correct
24 Correct 406 ms 720 KB Output is correct
25 Correct 412 ms 2648 KB Output is correct
26 Correct 439 ms 660 KB Output is correct
27 Correct 454 ms 656 KB Output is correct
28 Correct 449 ms 2648 KB Output is correct
29 Correct 445 ms 2632 KB Output is correct
30 Correct 485 ms 48216 KB Output is correct
31 Correct 475 ms 47412 KB Output is correct
32 Correct 489 ms 48208 KB Output is correct
33 Correct 484 ms 47004 KB Output is correct
34 Correct 483 ms 47328 KB Output is correct
35 Correct 460 ms 45396 KB Output is correct
36 Correct 471 ms 46932 KB Output is correct
37 Correct 492 ms 47384 KB Output is correct
38 Correct 476 ms 45908 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2032 ms 189796 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2648 KB Output is correct
2 Correct 1 ms 860 KB Output is correct
3 Correct 1 ms 980 KB Output is correct
4 Correct 2 ms 860 KB Output is correct
5 Correct 1 ms 2652 KB Output is correct
6 Correct 1 ms 860 KB Output is correct
7 Correct 1 ms 1112 KB Output is correct
8 Correct 1 ms 2648 KB Output is correct
9 Correct 1 ms 860 KB Output is correct
10 Correct 1 ms 860 KB Output is correct
11 Correct 1 ms 860 KB Output is correct
12 Correct 1 ms 860 KB Output is correct
13 Correct 1 ms 860 KB Output is correct
14 Correct 1 ms 2652 KB Output is correct
15 Correct 1 ms 856 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 1 ms 604 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 604 KB Output is correct
20 Correct 1 ms 604 KB Output is correct
21 Correct 394 ms 716 KB Output is correct
22 Correct 396 ms 2904 KB Output is correct
23 Correct 368 ms 716 KB Output is correct
24 Correct 406 ms 720 KB Output is correct
25 Correct 412 ms 2648 KB Output is correct
26 Correct 439 ms 660 KB Output is correct
27 Correct 454 ms 656 KB Output is correct
28 Correct 449 ms 2648 KB Output is correct
29 Correct 445 ms 2632 KB Output is correct
30 Correct 485 ms 48216 KB Output is correct
31 Correct 475 ms 47412 KB Output is correct
32 Correct 489 ms 48208 KB Output is correct
33 Correct 484 ms 47004 KB Output is correct
34 Correct 483 ms 47328 KB Output is correct
35 Correct 460 ms 45396 KB Output is correct
36 Correct 471 ms 46932 KB Output is correct
37 Correct 492 ms 47384 KB Output is correct
38 Correct 476 ms 45908 KB Output is correct
39 Execution timed out 2032 ms 189796 KB Time limit exceeded
40 Halted 0 ms 0 KB -