Comments

2201C — Rigged Bracket Sequence

Can someone help in understanding the solution? Didn't get proper understanding of the solution.

how did you decide that only fib0^2 + fib1^2 + .... fib^n = fibn*fib(n+1) is the only way to split the product into n+1 numbers?

Do you have some proof regarding this?

On AC_ACCSES DP SECTION — Book Shop, 3 years ago
0

Sorry I haven't written recursive . But iterative one :

include<bits/stdc++.h>

using namespace std;

int mod = 1e9 +7; int main(){ int n,x; cin>>n>>x; pair<int,int> h[n];

for(int i=0;i<n;i++){
    cin>>h[i].first;
}
for(int i=0;i<n;i++){
    cin>>h[i].second;
}
int dp[n+1][x+1];
dp[0][0]=0;
for(int i=0;i<=n;i++){
    dp[i][0] = 0;
}
for(int i=0;i<=x;i++){dp[0][i]=0;}
for(int i=1;i<=n;i++){
    for(int j=1;j<=x;j++){
        dp[i][j] = dp[i-1][j];
        if(j>=h[i-1].first){
            dp[i][j] = max(dp[i-1][j- h[i-1].first]+h[i-1].second,dp[i][j]);
        }
        dp[i][j] %= mod;
    }
}

cout<<dp[n][x]<<"\n"; }

On abhilash_8642Word Matcher, 4 years ago
0

I tried it but still i'm struck

On abhilash_8642Word Matcher, 4 years ago
0

I don't have it. It was asked in online assessment.

On abhilash_8642Word Matcher, 4 years ago
0

Auto comment: topic has been updated by abhilash_8642 (previous revision, new revision, compare).

On ArisCodeforces Round #764 (Div. 3), 4 years ago
0

I don't even know there was a thing called coding when i'am in school

On ilyakrasnovvCodeforces Round #773, 4 years ago
+2
int cf=x.second,cs=mp[a];
  • By map[a] you are creating a key value pair in map which will be iterated again in some cases until its key value overflows.
  • But you need to check whether such key exists.Because of this tle has occured.
  • My tle solution with same problem: Tle solution
  • The final solution: Accepted Solution
On ilyakrasnovvCodeforces Round #773, 4 years ago
-27

.

use faster i/o

code :

ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

Thnks for your help

130 day streak ... How did you get that much patience?

On AC_ACCSES DP SECTION — Book Shop, 4 years ago
0

this worked for me...

given an array of n elements, and q queries with two types 1 l r s e indicates flip bits of positions [s,s+1,....e] of subarray [al,..ar], 2 l r s e indicates print the number of set bits [s,s+1,...e] of subarray [al,...ar] n<=q<= 10^5, a[i] < 10^9 0<s<e<30

Can anyone help me in doing this?

can you send the code of 4th quesiton? So that i can see what is the approach of the quesion...

did you get 4th question ? I solved it in o(n*n) . Please share the approach! Thanks in advance