# |
제출 시각 |
아이디 |
문제 |
언어 |
결과 |
실행 시간 |
메모리 |
978315 |
2024-05-09T06:13:54 Z |
Amr |
Boat (APIO16_boat) |
C++17 |
|
900 ms |
239616 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 logn = 1e4;
ll seg[N*logn+N];
ll L[N*logn+N], R[N*logn+N];
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]];
}
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);
}
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)-1 << endl;
}
int main(){
//freopen("friday.in","r",stdin);
//freopen("friday.out","w",stdout);
fast;
while(TT--)
solve();
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
2652 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
2652 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
900 ms |
239616 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
2652 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |