# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
537059 |
2022-03-14T10:51:52 Z |
ammar2000 |
Boat (APIO16_boat) |
C++17 |
|
2000 ms |
9608 KB |
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define F first
#define S second
#define coy cout<<"YES\n"
#define con cout<<"NO\n"
#define co1 cout<<"-1\n"
#define sc(x) scanf("%lld",&x)
#define all(x) x.begin(),x.end()
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
const int SI=3e5+7;
ll INF=8e18+7;
int dx[] = {1 , -1 , 0 , 0};
int dy[] = {0 , 0 , 1 , -1};
int MOD=1e9+7;
ll n,a[SI],b[SI];
map <pair <ll,pair<ll,ll> >,ll> dp,vis;
ll solve(int in,int li,int ad)
{
if (in==n)
{
return ad>=0;
}
if (vis[{in,{li,ad}}])
return dp[{in,{li,ad}}];
vis[{in,{li,ad}}]=1;
ll ret=0;
for (int i=0;i+a[in]<=b[in];i++)
{
if (a[in]+i>a[li]+ad)
ret+=solve(in+1,in,i),ret%=MOD;
}
ret+=solve(in+1,li,ad);
return dp[{in,{li,ad}}]=ret%MOD;
}
int main()
{
fast
cin>>n;
for (int i=0;i<n;i++)
cin>>a[i]>>b[i];
cout << solve(0,0,-1);
// use scanf not cin
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
32 ms |
9608 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
32 ms |
9608 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2081 ms |
212 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
32 ms |
9608 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |