I'd emailed them and they had replied that they would be shifting the problems to codechef.
I'd emailed them and they had replied that they would be shifting the problems to codechef.
Solution using simple recursive DP(time:0.07):
#include<bits/stdc++.h>#define INF 99999999999#define endl '\n'typedef long long int ll;using namespace std;ll n,k;int node[1000001];ll dp1[1000001];bool dpp1[1000001];ll dp2[1000001];bool dpp2[1000001];ll fr(int i){if(i<k)return -INF;if(i==k){dp1[i]=0;return 0;}if(dpp1[i])return dp1[i];
What's wrong in this solution(passed subtask1 bot got 4WA's in subtask 2)?
Thanks in advance!
code:[C++] SaveSpaceManSpiffZCOCodeFormatingNotWorkingBelow
Edit:The code shown below is not right check the pastebin link above
Commonlounge codebox seems to be messing with the format as well as its content
#include#define endl '\n'using namespace std;int n, m, k;unsigned long int grid[2505][2505];bool valid[2505][2505];int blaster[2505][4];void makeTrue(){
Solution(dp_recursive):
#include<iostream>#include<algorithm>#define endl '\n'#define INF 4000000000typedef long long int ll;using namespace std;int n;unsigned int pr[200005];ll dp[200005][4];bool check[200005][4];ll ans(ll ind, int res){if(n<3){return pr[0]+pr[1];}if(res==3){return -INF;}
Solution:
#include<iostream>#include<algorithm>#define INF -20000#define endl '\n'using namespace std;bool valid[505][505];bool possible(int n){unsigned long int p[n+1][n+1];for(int i=0; i<=n; i++){for(int j=0;j<=n;j++)p[i][j]=0;}p[1][1]=1;for(int i=1; i<=n; i++){for(int j=1; j<=n; j++){if(valid[i-1][j-1])p[i][j]+= p[i-1][j] + p[i][j-1];elsep[i][j]=0;}
My solution:-
#include <iostream>using namespace std;int main(){std::ios::sync_with_stdio(false);long int n;cin >>n;long int z;long int r=0,k=0,pos,coun=0,j,cm=0,b;for(long int i =0;i<n;i++){if(k==0){coun=0;j=i+1;}cin >> z;if(z==1)k++;else k--;if(k>r){r=k;pos=i+1;}coun++;if(coun>cm){cm=coun;b=j;}}cout << r << " " << pos << " " << cm << " " << b << endl;