# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1015088 |
2024-07-06T05:10:36 Z |
vjudge1 |
Boat (APIO16_boat) |
C++17 |
|
2000 ms |
454396 KB |
#include <bits/stdc++.h>
using namespace std;
const int M = 1e6 + 1, mod = 1e9 + 7;
int fen[M+1];
void modify(int p,int x)
{
p++;
while (p<=M)
{
fen[p]+=x;
fen[p]%=mod;
p+=p&-p;
}
}
int get(int p)
{
int ans=0;
p++;
while (p)
{
ans+=fen[p];
ans%=mod;
p-=p&-p;
}
return ans;
}
int main()
{
int n;
cin>>n;
int a[n],b[n];
set<int> se;
for (int i=0;i<n;i++)
{
cin>>a[i]>>b[i];
for (int j=a[i];j<=b[i];j++)
se.insert(j);
}
map<int,int> mp;
for (int i:se)
mp[i]=mp.size()+1;
modify(0,1);
for (int i=0;i<n;i++)
{
a[i]=mp[a[i]],b[i]=mp[b[i]];
for (int j=b[i];j>=a[i];j--)
modify(j,get(j-1));
}
cout<<get(M)-1<<endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
344 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
344 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
1 ms |
348 KB |
Output is correct |
19 |
Correct |
1 ms |
348 KB |
Output is correct |
20 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
344 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
344 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
1 ms |
348 KB |
Output is correct |
19 |
Correct |
1 ms |
348 KB |
Output is correct |
20 |
Correct |
1 ms |
348 KB |
Output is correct |
21 |
Correct |
56 ms |
940 KB |
Output is correct |
22 |
Correct |
56 ms |
856 KB |
Output is correct |
23 |
Correct |
51 ms |
960 KB |
Output is correct |
24 |
Correct |
60 ms |
860 KB |
Output is correct |
25 |
Correct |
59 ms |
860 KB |
Output is correct |
26 |
Correct |
59 ms |
620 KB |
Output is correct |
27 |
Correct |
60 ms |
836 KB |
Output is correct |
28 |
Correct |
64 ms |
600 KB |
Output is correct |
29 |
Correct |
60 ms |
600 KB |
Output is correct |
30 |
Correct |
379 ms |
96996 KB |
Output is correct |
31 |
Correct |
371 ms |
95244 KB |
Output is correct |
32 |
Correct |
355 ms |
97084 KB |
Output is correct |
33 |
Correct |
358 ms |
94548 KB |
Output is correct |
34 |
Correct |
379 ms |
95320 KB |
Output is correct |
35 |
Correct |
300 ms |
91016 KB |
Output is correct |
36 |
Correct |
333 ms |
94232 KB |
Output is correct |
37 |
Correct |
327 ms |
95316 KB |
Output is correct |
38 |
Correct |
331 ms |
92240 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2047 ms |
454396 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
344 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
344 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
1 ms |
348 KB |
Output is correct |
19 |
Correct |
1 ms |
348 KB |
Output is correct |
20 |
Correct |
1 ms |
348 KB |
Output is correct |
21 |
Correct |
56 ms |
940 KB |
Output is correct |
22 |
Correct |
56 ms |
856 KB |
Output is correct |
23 |
Correct |
51 ms |
960 KB |
Output is correct |
24 |
Correct |
60 ms |
860 KB |
Output is correct |
25 |
Correct |
59 ms |
860 KB |
Output is correct |
26 |
Correct |
59 ms |
620 KB |
Output is correct |
27 |
Correct |
60 ms |
836 KB |
Output is correct |
28 |
Correct |
64 ms |
600 KB |
Output is correct |
29 |
Correct |
60 ms |
600 KB |
Output is correct |
30 |
Correct |
379 ms |
96996 KB |
Output is correct |
31 |
Correct |
371 ms |
95244 KB |
Output is correct |
32 |
Correct |
355 ms |
97084 KB |
Output is correct |
33 |
Correct |
358 ms |
94548 KB |
Output is correct |
34 |
Correct |
379 ms |
95320 KB |
Output is correct |
35 |
Correct |
300 ms |
91016 KB |
Output is correct |
36 |
Correct |
333 ms |
94232 KB |
Output is correct |
37 |
Correct |
327 ms |
95316 KB |
Output is correct |
38 |
Correct |
331 ms |
92240 KB |
Output is correct |
39 |
Execution timed out |
2047 ms |
454396 KB |
Time limit exceeded |
40 |
Halted |
0 ms |
0 KB |
- |