Hey there!! I am stuck in this problem for quit some time, can you guys can please help me…
It is CSES DP coin combination( CSES - Coin Combinations I ) , It results in TLE in 3 test cases.
using namespace std;
// #define int long long
int INF = 1e9+7;
int n , m ;
for(int i = 0;i<n;i++) cin>>a[i];
c = 1;
for(int i = 1;i<=m;i++)
for(int j = 0;j<n;j++)
Your help will be appreciated.
And read a article about cache misses, I guess there is one on codeforces about it
if(i>=a[j]) ? In place of subtracting if(i-a[j])>=0. This question’s constraints are too tight. The answer is right most certainly, you shouldn’t bother too much.
it still not working, I checked out some accepted solution but they are same as mine ,but thanks a lot for your efforts.
Have you tried using memoization?? It might reduce time because some operations will be precomputed.
Try sorting the array and then when a[j] becomes greater than i breakout of the inner for loop, maybe this can improve the runtime