Submission #123940

# Submission time Handle Problem Language Result Execution time Memory
123940 2019-07-02T09:56:16 Z RafikHachana Boat (APIO16_boat) C++14
0 / 100
2000 ms 8184 KB
#include<bits/stdc++.h>
using namespace std;

int n;
vector<int> a,b;
map<pair<int,int>,int> m;

int dp(int i,int val)
{
  //cout<<val<<endl;
  if(i==n) return (int)(val!=-1);
  if(m.find({i,val})!=m.end()) return m[{i,val}];
  int r = dp(i+1,val);
  for(int j=max(val,a[i]);j<=b[i];j++) r+=dp(i+1,j+1);
  return m[{i,val}] = r;
}

int main()
{
  cin>>n;
  a.resize(n);
  b.resize(n);
  for(int i=0;i<n;i++)
  {
    cin>>a[i]>>b[i];
  }
  cout<<dp(0,-1)<<endl;
}
# Verdict Execution time Memory Grader output
1 Incorrect 87 ms 8184 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 87 ms 8184 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2040 ms 376 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 87 ms 8184 KB Output isn't correct
2 Halted 0 ms 0 KB -