# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
730753 |
2023-04-26T11:03:30 Z |
bgnbvnbv |
Boat (APIO16_boat) |
C++14 |
|
396 ms |
524288 KB |
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int mod=(int)1e9+7;
const int maxn=505;
int sz,a[maxn],b[maxn];
vector<int>v,s;
int bit[1000005];
void update(int pos,int val)
{
while(pos<=sz)
{
bit[pos]+=val;
if(bit[pos]>=mod) bit[pos]-=mod;
pos+=pos&(-pos);
}
}
int get(int pos)
{
int ans=0;
while(pos>0)
{
ans+=bit[pos];
if(ans>=mod) ans-=mod;
pos-=(pos&(-pos));
}
return ans;
}
int n;
signed main()
{
ios_base::sync_with_stdio(false); cin.tie(NULL);
cin >> n;
for(int i=1;i<=n;i++)
{
cin >> a[i] >> b[i];
for(int j=a[i];j<=b[i];j++) v.push_back(j);
}
sort(v.begin(),v.end());
s.push_back(-1);
s.push_back(0);
for(int i=0;i<v.size();i++)
{
if(i==0||v[i]!=v[i-1]) s.push_back(v[i]);
}
swap(v,s);
sz=v.size()-1;
update(1,1);
for(int i=1;i<=n;i++)
{
int l=lower_bound(v.begin(),v.end(),a[i])-v.begin();
int r=lower_bound(v.begin(),v.end(),b[i])-v.begin();
for(int j=r;j>=l;j--)
{
update(j,get(j-1));
}
}
cout << (get(sz)-1+mod)%mod;
}
Compilation message
boat.cpp: In function 'int main()':
boat.cpp:43:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
43 | for(int i=0;i<v.size();i++)
| ~^~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
336 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
344 KB |
Output is correct |
12 |
Correct |
1 ms |
352 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
1 ms |
340 KB |
Output is correct |
19 |
Correct |
1 ms |
340 KB |
Output is correct |
20 |
Correct |
1 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
336 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
344 KB |
Output is correct |
12 |
Correct |
1 ms |
352 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
1 ms |
340 KB |
Output is correct |
19 |
Correct |
1 ms |
340 KB |
Output is correct |
20 |
Correct |
1 ms |
344 KB |
Output is correct |
21 |
Correct |
52 ms |
8648 KB |
Output is correct |
22 |
Correct |
51 ms |
8648 KB |
Output is correct |
23 |
Correct |
48 ms |
8648 KB |
Output is correct |
24 |
Correct |
55 ms |
8648 KB |
Output is correct |
25 |
Correct |
54 ms |
8644 KB |
Output is correct |
26 |
Correct |
56 ms |
8644 KB |
Output is correct |
27 |
Correct |
56 ms |
8776 KB |
Output is correct |
28 |
Correct |
55 ms |
8648 KB |
Output is correct |
29 |
Correct |
56 ms |
8644 KB |
Output is correct |
30 |
Correct |
85 ms |
23712 KB |
Output is correct |
31 |
Correct |
99 ms |
23200 KB |
Output is correct |
32 |
Correct |
85 ms |
23656 KB |
Output is correct |
33 |
Correct |
86 ms |
23000 KB |
Output is correct |
34 |
Correct |
84 ms |
23200 KB |
Output is correct |
35 |
Correct |
92 ms |
22176 KB |
Output is correct |
36 |
Correct |
94 ms |
22972 KB |
Output is correct |
37 |
Correct |
94 ms |
23172 KB |
Output is correct |
38 |
Correct |
94 ms |
22420 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
396 ms |
524288 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
336 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
344 KB |
Output is correct |
12 |
Correct |
1 ms |
352 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
1 ms |
340 KB |
Output is correct |
19 |
Correct |
1 ms |
340 KB |
Output is correct |
20 |
Correct |
1 ms |
344 KB |
Output is correct |
21 |
Correct |
52 ms |
8648 KB |
Output is correct |
22 |
Correct |
51 ms |
8648 KB |
Output is correct |
23 |
Correct |
48 ms |
8648 KB |
Output is correct |
24 |
Correct |
55 ms |
8648 KB |
Output is correct |
25 |
Correct |
54 ms |
8644 KB |
Output is correct |
26 |
Correct |
56 ms |
8644 KB |
Output is correct |
27 |
Correct |
56 ms |
8776 KB |
Output is correct |
28 |
Correct |
55 ms |
8648 KB |
Output is correct |
29 |
Correct |
56 ms |
8644 KB |
Output is correct |
30 |
Correct |
85 ms |
23712 KB |
Output is correct |
31 |
Correct |
99 ms |
23200 KB |
Output is correct |
32 |
Correct |
85 ms |
23656 KB |
Output is correct |
33 |
Correct |
86 ms |
23000 KB |
Output is correct |
34 |
Correct |
84 ms |
23200 KB |
Output is correct |
35 |
Correct |
92 ms |
22176 KB |
Output is correct |
36 |
Correct |
94 ms |
22972 KB |
Output is correct |
37 |
Correct |
94 ms |
23172 KB |
Output is correct |
38 |
Correct |
94 ms |
22420 KB |
Output is correct |
39 |
Runtime error |
396 ms |
524288 KB |
Execution killed with signal 9 |
40 |
Halted |
0 ms |
0 KB |
- |