|
|
вернуться в форумWHY WRONG ANSWER ON 17 TEST??????????????HELP ME! #include <iostream.h> int main() { int mas[10000],x,k=0,p,sum=0,a[5000]; unsigned long int i,j,Q,N; cin>>N; for(p=1;p<=N;p++) { cin>>a[p]; } cin>>Q; for(x=1;x<=Q;x++) { sum=0; cin>>i>>j; for(p=i;p<=j;p++) { sum+=a[p]; } mas[k]=sum; k++; } for(p=0;p<Q;p++) cout<<mas[p]<<endl; return 0; } Re: WHY WRONG ANSWER ON 17 TEST??????????????HELP ME! Use DP. Re: WHY WRONG ANSWER ON 17 TEST??????????????HELP ME! DEAR MASTER OF C++!!!DON'T COUNT SUM!!!INSTEAD OF COUNT SUM USE: a[k]=a[k]+a[k-1]; AND AT ANOTHER CYCLE for(x=1;x<=Q;x++) USE b[k]=a[j]-a[i-1]; cout<<b[k]<<endl; DON'T USE SUM! GOOD LUCK!!!!! |
|
|