# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
399330 |
2021-05-05T15:10:22 Z |
jeqcho |
Boat (APIO16_boat) |
C++17 |
|
2000 ms |
286708 KB |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpi;
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)
#define pb push_back
#define rsz resize
#define sz(x) int(x.size())
#define all(x) begin(x), end(x)
#define fi first
#define se second
// subtask 1
int const N=5e2+3;
int a[N],b[N];
int const D=1e6+3;
ll dp[2][D];
ll mod =1e9+7;
int main()
{
ios_base::sync_with_stdio(0); cin.tie(0);
int n;
cin>>n;
set<int> st;
F0R(i,n)
{
cin>>a[i]>>b[i];
FOR(j,a[i],b[i]+1)
{
st.insert(j);
}
}
vi v(all(st));
map<int,int>mp;
F0R(i,sz(st))
{
mp[v[i]]=i+1;
}
F0R(i,n)
{
a[i]=mp[a[i]];
b[i]=mp[b[i]];
}
F0R(j,sz(st)+1)
{
dp[0][j]=0;
}
dp[0][0]=1;
int pre=0;
int cur=1;
F0R(i,n)
{
F0R(j,sz(st)+1)
{
dp[cur][j]=dp[pre][j];
}
ll sum=0;
F0R(j,b[i]+1)
{
if(j>=a[i])
{
dp[cur][j]+=sum;
dp[cur][j]%=mod;
}
sum += dp[pre][j];
sum%=mod;
}
swap(cur,pre);
}
ll ans=0;
FOR(j,1,sz(st)+1)
{
ans+=dp[pre][j];
ans%=mod;
}
cout<<ans<<'\n';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
332 KB |
Output is correct |
2 |
Correct |
2 ms |
332 KB |
Output is correct |
3 |
Correct |
2 ms |
332 KB |
Output is correct |
4 |
Correct |
2 ms |
332 KB |
Output is correct |
5 |
Correct |
2 ms |
332 KB |
Output is correct |
6 |
Correct |
2 ms |
332 KB |
Output is correct |
7 |
Correct |
2 ms |
332 KB |
Output is correct |
8 |
Correct |
2 ms |
388 KB |
Output is correct |
9 |
Correct |
2 ms |
332 KB |
Output is correct |
10 |
Correct |
2 ms |
332 KB |
Output is correct |
11 |
Correct |
2 ms |
332 KB |
Output is correct |
12 |
Correct |
2 ms |
332 KB |
Output is correct |
13 |
Correct |
2 ms |
332 KB |
Output is correct |
14 |
Correct |
2 ms |
332 KB |
Output is correct |
15 |
Correct |
2 ms |
332 KB |
Output is correct |
16 |
Correct |
1 ms |
332 KB |
Output is correct |
17 |
Correct |
1 ms |
332 KB |
Output is correct |
18 |
Correct |
1 ms |
332 KB |
Output is correct |
19 |
Correct |
1 ms |
332 KB |
Output is correct |
20 |
Correct |
1 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
332 KB |
Output is correct |
2 |
Correct |
2 ms |
332 KB |
Output is correct |
3 |
Correct |
2 ms |
332 KB |
Output is correct |
4 |
Correct |
2 ms |
332 KB |
Output is correct |
5 |
Correct |
2 ms |
332 KB |
Output is correct |
6 |
Correct |
2 ms |
332 KB |
Output is correct |
7 |
Correct |
2 ms |
332 KB |
Output is correct |
8 |
Correct |
2 ms |
388 KB |
Output is correct |
9 |
Correct |
2 ms |
332 KB |
Output is correct |
10 |
Correct |
2 ms |
332 KB |
Output is correct |
11 |
Correct |
2 ms |
332 KB |
Output is correct |
12 |
Correct |
2 ms |
332 KB |
Output is correct |
13 |
Correct |
2 ms |
332 KB |
Output is correct |
14 |
Correct |
2 ms |
332 KB |
Output is correct |
15 |
Correct |
2 ms |
332 KB |
Output is correct |
16 |
Correct |
1 ms |
332 KB |
Output is correct |
17 |
Correct |
1 ms |
332 KB |
Output is correct |
18 |
Correct |
1 ms |
332 KB |
Output is correct |
19 |
Correct |
1 ms |
332 KB |
Output is correct |
20 |
Correct |
1 ms |
332 KB |
Output is correct |
21 |
Correct |
62 ms |
820 KB |
Output is correct |
22 |
Correct |
62 ms |
824 KB |
Output is correct |
23 |
Correct |
60 ms |
816 KB |
Output is correct |
24 |
Correct |
64 ms |
816 KB |
Output is correct |
25 |
Correct |
66 ms |
916 KB |
Output is correct |
26 |
Correct |
58 ms |
708 KB |
Output is correct |
27 |
Correct |
66 ms |
764 KB |
Output is correct |
28 |
Correct |
57 ms |
708 KB |
Output is correct |
29 |
Correct |
59 ms |
756 KB |
Output is correct |
30 |
Execution timed out |
2008 ms |
112576 KB |
Time limit exceeded |
31 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2100 ms |
286708 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
332 KB |
Output is correct |
2 |
Correct |
2 ms |
332 KB |
Output is correct |
3 |
Correct |
2 ms |
332 KB |
Output is correct |
4 |
Correct |
2 ms |
332 KB |
Output is correct |
5 |
Correct |
2 ms |
332 KB |
Output is correct |
6 |
Correct |
2 ms |
332 KB |
Output is correct |
7 |
Correct |
2 ms |
332 KB |
Output is correct |
8 |
Correct |
2 ms |
388 KB |
Output is correct |
9 |
Correct |
2 ms |
332 KB |
Output is correct |
10 |
Correct |
2 ms |
332 KB |
Output is correct |
11 |
Correct |
2 ms |
332 KB |
Output is correct |
12 |
Correct |
2 ms |
332 KB |
Output is correct |
13 |
Correct |
2 ms |
332 KB |
Output is correct |
14 |
Correct |
2 ms |
332 KB |
Output is correct |
15 |
Correct |
2 ms |
332 KB |
Output is correct |
16 |
Correct |
1 ms |
332 KB |
Output is correct |
17 |
Correct |
1 ms |
332 KB |
Output is correct |
18 |
Correct |
1 ms |
332 KB |
Output is correct |
19 |
Correct |
1 ms |
332 KB |
Output is correct |
20 |
Correct |
1 ms |
332 KB |
Output is correct |
21 |
Correct |
62 ms |
820 KB |
Output is correct |
22 |
Correct |
62 ms |
824 KB |
Output is correct |
23 |
Correct |
60 ms |
816 KB |
Output is correct |
24 |
Correct |
64 ms |
816 KB |
Output is correct |
25 |
Correct |
66 ms |
916 KB |
Output is correct |
26 |
Correct |
58 ms |
708 KB |
Output is correct |
27 |
Correct |
66 ms |
764 KB |
Output is correct |
28 |
Correct |
57 ms |
708 KB |
Output is correct |
29 |
Correct |
59 ms |
756 KB |
Output is correct |
30 |
Execution timed out |
2008 ms |
112576 KB |
Time limit exceeded |
31 |
Halted |
0 ms |
0 KB |
- |