#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <set>
#include <map>
#include <time.h>
using namespace std;
long long MOD=1e9+7,now=1;
long long a[505];
long long b[505];
struct A
{
long long l,r;
long long nxl,nxr;
long long con;
}Node[2000005];
void build(long long l,long long r,long long here)
{
Node[here].l=l;
Node[here].r=r;
Node[here].con=0;
Node[here].nxl=-1;
Node[here].nxr=-1;
}
long long Find(long long l,long long r,long long here)
{
if(here<0) return 0;
if(Node[here].l==l&&Node[here].r==r) return Node[here].con;
if(r<=(Node[here].l+Node[here].r)/2) return Find(l,r,Node[here].nxl);
if(l>(Node[here].l+Node[here].r)/2) return Find(l,r,Node[here].nxr);
return (Find(l,(Node[here].l+Node[here].r)/2,Node[here].nxl)+Find((Node[here].l+Node[here].r)/2+1,r,Node[here].nxr))%MOD;
}
void cha(long long where,long long con,long long here)
{
//printf("%lld %lld %lld %lld %lld\n",where,con,here,Node[here].l,Node[here].r);
Node[here].con+=con;
Node[here].con%=MOD;
if(Node[here].l==where&&Node[here].r==where)
{
return;
}
if(where<=(Node[here].l+Node[here].r)/2)
{
if(Node[here].nxl==-1)
{
Node[here].nxl=now++;
build(Node[here].l,(Node[here].l+Node[here].r)/2,Node[here].nxl);
}
cha(where,con,Node[here].nxl);
}
else
{
if(Node[here].nxr==-1)
{
Node[here].nxr=now++;
build((Node[here].l+Node[here].r)/2+1,Node[here].r,Node[here].nxr);
}
cha(where,con,Node[here].nxr);
}
}
int main()
{
//srand(time(NULL));
long long N,M,i,j;
scanf("%lld",&N);
for(i=1;i<=N;i++) scanf("%lld %lld",&a[i],&b[i]);
build(0,1e9,0);
cha(0,1,0);
//printf("aa\n");
for(i=1;i<=N;i++)
{
for(j=b[i];j>=a[i];j--)
{
//printf("%lld %lld\n",i,j);
cha(j,Find(0,j-1,0),0);
}
}
printf("%lld\n",Find(1,1e9,0));
return 0;
}
/*
2
32 47
18 78
*/
Compilation message
boat.cpp: In function 'int main()':
boat.cpp:68:17: warning: unused variable 'M' [-Wunused-variable]
long long N,M,i,j;
^
boat.cpp:69:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%lld",&N);
~~~~~^~~~~~~~~~~
boat.cpp:70:28: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
for(i=1;i<=N;i++) scanf("%lld %lld",&a[i],&b[i]);
~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
768 KB |
Output is correct |
2 |
Correct |
1 ms |
768 KB |
Output is correct |
3 |
Correct |
1 ms |
768 KB |
Output is correct |
4 |
Correct |
1 ms |
768 KB |
Output is correct |
5 |
Correct |
1 ms |
768 KB |
Output is correct |
6 |
Correct |
1 ms |
768 KB |
Output is correct |
7 |
Correct |
1 ms |
768 KB |
Output is correct |
8 |
Correct |
1 ms |
768 KB |
Output is correct |
9 |
Correct |
1 ms |
768 KB |
Output is correct |
10 |
Correct |
1 ms |
768 KB |
Output is correct |
11 |
Correct |
1 ms |
768 KB |
Output is correct |
12 |
Correct |
1 ms |
768 KB |
Output is correct |
13 |
Correct |
1 ms |
768 KB |
Output is correct |
14 |
Correct |
1 ms |
768 KB |
Output is correct |
15 |
Correct |
1 ms |
768 KB |
Output is correct |
16 |
Correct |
1 ms |
384 KB |
Output is correct |
17 |
Correct |
1 ms |
384 KB |
Output is correct |
18 |
Correct |
1 ms |
384 KB |
Output is correct |
19 |
Correct |
1 ms |
384 KB |
Output is correct |
20 |
Correct |
1 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
768 KB |
Output is correct |
2 |
Correct |
1 ms |
768 KB |
Output is correct |
3 |
Correct |
1 ms |
768 KB |
Output is correct |
4 |
Correct |
1 ms |
768 KB |
Output is correct |
5 |
Correct |
1 ms |
768 KB |
Output is correct |
6 |
Correct |
1 ms |
768 KB |
Output is correct |
7 |
Correct |
1 ms |
768 KB |
Output is correct |
8 |
Correct |
1 ms |
768 KB |
Output is correct |
9 |
Correct |
1 ms |
768 KB |
Output is correct |
10 |
Correct |
1 ms |
768 KB |
Output is correct |
11 |
Correct |
1 ms |
768 KB |
Output is correct |
12 |
Correct |
1 ms |
768 KB |
Output is correct |
13 |
Correct |
1 ms |
768 KB |
Output is correct |
14 |
Correct |
1 ms |
768 KB |
Output is correct |
15 |
Correct |
1 ms |
768 KB |
Output is correct |
16 |
Correct |
1 ms |
384 KB |
Output is correct |
17 |
Correct |
1 ms |
384 KB |
Output is correct |
18 |
Correct |
1 ms |
384 KB |
Output is correct |
19 |
Correct |
1 ms |
384 KB |
Output is correct |
20 |
Correct |
1 ms |
384 KB |
Output is correct |
21 |
Correct |
317 ms |
888 KB |
Output is correct |
22 |
Correct |
318 ms |
768 KB |
Output is correct |
23 |
Correct |
296 ms |
768 KB |
Output is correct |
24 |
Correct |
333 ms |
896 KB |
Output is correct |
25 |
Correct |
333 ms |
792 KB |
Output is correct |
26 |
Correct |
365 ms |
632 KB |
Output is correct |
27 |
Correct |
353 ms |
612 KB |
Output is correct |
28 |
Correct |
359 ms |
792 KB |
Output is correct |
29 |
Correct |
350 ms |
676 KB |
Output is correct |
30 |
Correct |
438 ms |
77688 KB |
Output is correct |
31 |
Correct |
439 ms |
76376 KB |
Output is correct |
32 |
Correct |
431 ms |
77816 KB |
Output is correct |
33 |
Correct |
435 ms |
75768 KB |
Output is correct |
34 |
Correct |
441 ms |
76536 KB |
Output is correct |
35 |
Correct |
398 ms |
72952 KB |
Output is correct |
36 |
Correct |
414 ms |
75640 KB |
Output is correct |
37 |
Correct |
417 ms |
76408 KB |
Output is correct |
38 |
Correct |
403 ms |
73848 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
550 ms |
159212 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
768 KB |
Output is correct |
2 |
Correct |
1 ms |
768 KB |
Output is correct |
3 |
Correct |
1 ms |
768 KB |
Output is correct |
4 |
Correct |
1 ms |
768 KB |
Output is correct |
5 |
Correct |
1 ms |
768 KB |
Output is correct |
6 |
Correct |
1 ms |
768 KB |
Output is correct |
7 |
Correct |
1 ms |
768 KB |
Output is correct |
8 |
Correct |
1 ms |
768 KB |
Output is correct |
9 |
Correct |
1 ms |
768 KB |
Output is correct |
10 |
Correct |
1 ms |
768 KB |
Output is correct |
11 |
Correct |
1 ms |
768 KB |
Output is correct |
12 |
Correct |
1 ms |
768 KB |
Output is correct |
13 |
Correct |
1 ms |
768 KB |
Output is correct |
14 |
Correct |
1 ms |
768 KB |
Output is correct |
15 |
Correct |
1 ms |
768 KB |
Output is correct |
16 |
Correct |
1 ms |
384 KB |
Output is correct |
17 |
Correct |
1 ms |
384 KB |
Output is correct |
18 |
Correct |
1 ms |
384 KB |
Output is correct |
19 |
Correct |
1 ms |
384 KB |
Output is correct |
20 |
Correct |
1 ms |
384 KB |
Output is correct |
21 |
Correct |
317 ms |
888 KB |
Output is correct |
22 |
Correct |
318 ms |
768 KB |
Output is correct |
23 |
Correct |
296 ms |
768 KB |
Output is correct |
24 |
Correct |
333 ms |
896 KB |
Output is correct |
25 |
Correct |
333 ms |
792 KB |
Output is correct |
26 |
Correct |
365 ms |
632 KB |
Output is correct |
27 |
Correct |
353 ms |
612 KB |
Output is correct |
28 |
Correct |
359 ms |
792 KB |
Output is correct |
29 |
Correct |
350 ms |
676 KB |
Output is correct |
30 |
Correct |
438 ms |
77688 KB |
Output is correct |
31 |
Correct |
439 ms |
76376 KB |
Output is correct |
32 |
Correct |
431 ms |
77816 KB |
Output is correct |
33 |
Correct |
435 ms |
75768 KB |
Output is correct |
34 |
Correct |
441 ms |
76536 KB |
Output is correct |
35 |
Correct |
398 ms |
72952 KB |
Output is correct |
36 |
Correct |
414 ms |
75640 KB |
Output is correct |
37 |
Correct |
417 ms |
76408 KB |
Output is correct |
38 |
Correct |
403 ms |
73848 KB |
Output is correct |
39 |
Runtime error |
550 ms |
159212 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
40 |
Halted |
0 ms |
0 KB |
- |