We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Can s.o help me PLZ?
my solution does not follow the algorithmic way described, but I'm wondering why it is not correct for test cases #4 to #9, (it is ok for the #0 to #3)
can anyone help me to find the problem of code?
#include<cmath>#include<cstdio>#include<vector>#include<iostream>#include<algorithm>usingnamespacestd;intmain(){intn,k,temp,sum=0,sTemp=0;cin>>n>>k;vector<int>v;vector<int>vSum;for(inti=0;i<n;i++){cin>>temp;v.push_back(temp);sum+=temp;}// for K states, we have k+1 type of orderingfor(intj=0;j<=k;j++){sTemp=sum;for(inti=j;i<n;i=i+k+1){sTemp-=v[i];}vSum.push_back(sTemp);}sort(vSum.begin(),vSum.end());cout<<vSum[vSum.size()-1]<<endl;return0;}
Billboards
You are viewing a single comment's thread. Return to all comments →
Can s.o help me PLZ? my solution does not follow the algorithmic way described, but I'm wondering why it is not correct for test cases #4 to #9, (it is ok for the #0 to #3) can anyone help me to find the problem of code?